Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001032

Re: [PHP] [PHP4] $fp = fopen( "news.txt", 'a' ); // 'a' = append! Wah! From: Joe Brown (joebrown <email protected>)
Date: 03/25/01

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 ( <email protected>)"" <ddogbruce <email protected>> wrote in message
news:3ABE423F.C7709DEB <email protected>
> 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 <email protected>
> For additional commands, e-mail: php-general-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>