Hi Forum, and thanks for reading my issue.
I am trying to append to a file using the script witten from the PHP website, but I have lost all efforts in trying to get it to work. I keep getting this error:
Warning: fgets(): 2 is not a valid stream resource in C:\Documents and Settings\Administrator\Local Settings\Temp\prev16~.php on line 9
Warning: fclose(): 2 is not a valid stream resource in C:\Documents and Settings\Administrator\Local Settings\Temp\prev16~.php on line 10
Here is the Code Producing the error:
<?php
$name=$_POST['name'];
$file_name = "names.dat";
$fp = fopen($file_name, "a");
//write to the filefwrite($fp, "$name\n");
fclose($fp);
//read from the file$fp = fopen($file_name, "r");
echo "<ul>";
while($line = fgets($fp)){ echo "<li>$line";
}echo "</ul>";fclose($fp);
?>
By The way, This is the garbage that is returned to me:
"; while($line = fgets($fp)){ echo
"$line"; }echo "";fclose($fp); ?>
Thanks for any help on this issue.