Re: [PHP4] $fp = fopen( "news.txt", 'a' ); // 'a' = append! Wah!

From: Date: Sun, 25 Mar 2001 20:07:24 +0000
Subject: Re: [PHP4] $fp = fopen( "news.txt", 'a' ); // 'a' = append! Wah!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-45510@lists.php.net to get a copy of this message
Re-create the file. You're most of the way there. if( $formSubmit ) { echo "Your news has been processed."; $filename = "news.txt"; //This is simpler than messing with an array of the original content. $fp = fopen ($filename, "r"); $newsSubmit = fread ($fd, filesize ($filename)); fclose ($fp); $fp = fopen( $filename, "w" ); // change append to write (a to w) fwrite( $fp, $frmName ); //write the new fwrite( $fp, $newsSubmit); //write the old fclose( $fp ); } else { include ( "newsForm.php" ); } if you want to use fseek, then try this: if( $formSubmit ) { echo "Your news has been processed."; $filename = "news.txt"; //This is simpler than messing with an array of the original content. $fp = fopen ($filename, "r+"); $newsSubmit = fread ($fd, filesize ($filename)); fseek($fp,0); fwrite( $fp, $frmName ); //write the new fwrite( $fp, $newsSubmit); //write the old fclose( $fp ); } else { include ( "newsForm.php" ); } ""Dddogbruce (@home.com)"" <ddogbruce@home.com> wrote in message news:3ABE423F.C7709DEB@home.com... > Ok, with this fseek.. > > Could you give me an example of how to implement it? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#45510) next »