PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 9th, 2004, 04:57 PM
LithiumFire LithiumFire is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 LithiumFire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is not too hard i think, please help

Greetings everyone.

I got this system, it puts in a text file information i specify with a form, this is the URI:
http://tampico.org.mx/~vhoc/cat/altas.php

This is the code I wrote:
PHP Code:
<?php
  $filename 
'base.txt';
  
$contenidonom $_POST['nombre'];
  
$contenidoapa $_POST['apaterno'];
  
$contenidoama $_POST['amaterno'];
  
$comma ",";
  
$line "\r\n";
  
$quotes '"';
  
  
// If file is writable...
  
if (is_writable($filename)) {
  
     
// Open the file in 'a' mode
     
if (!$gestor fopen($filename'a')) {
           echo 
"No se puede leer en la base, compruebe los permisos de $filename";
           exit;
     }
  
      
// put a quote
      
if (fwrite($gestor$quotes) === FALSE) {
          echo 
"No se puede escribir en la base, compruebe los permisos de $filename";
          exit;
      }
  
      
// put the first field "$contenidonom"
      
if (fwrite($gestor$contenidonom) === FALSE) {
          echo 
"No se puede escribir en la base, compruebe los permisos de $filename";
          exit;
      }
  
      
// put quote
     
if (fwrite($gestor$quotes) === FALSE) {
         echo 
"No se puede escribir en la base, compruebe los permisos de $filename";
         exit;
     }
  
      
// put a comma
      
if (fwrite($gestor$comma) === FALSE) {
          echo 
"No se puede escribir en la base, compruebe los permisos de $filename";
          exit;
      }
  
?>


The result in the base.txt file is:

"nombre","apaterno","amaterno"

But i want to add an ID number so i can get this:

"1","nombre","apaterno","amaterno"
"2","foo","bar","com"

and so on..

I need your help so the script puts the ID numbers by itself when a new line is added. How should I do it?

I'm trying with this code
PHP Code:
for ($id=1;$id<count$id++)
      
      if (
fwrite($gestor$id)=== FALSE) {
          echo 
"No se puede escribir en la vase, compruebe los permisos de $filename";
          exit;
      } 


But I don't get what I want.

I would appreciatte your help, and excuseme if my english is't good.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > This is not too hard i think, please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway