probe wrote:ok... im trying to get this script to work (nothing fancy)
i have form located at http://zeldago.com/simpsons/comments.html
and then it outputs to comments.php with this code
- Code: Select all
<?php
$file = "abc.txt";
$file_handle=fopen($file, "r+");
$now = date("y-m-d");
fputs($file_handle, $name."\n".$now."\n".$comment);
fclose($file_handle);
?>
and its suppose to write to the top of the file without overwriting anything underneith... but for some reason it likes to write over top of ur last post... i dont know why. r+ and w+ do the same thing for this instance... and a+ just ads it underneith all the older posts...
basically i want the newer posts to appear first but cant get it to work... any suggestions???[/code]
Interesting how you can write file with right read-only?
r+ - read-only
w+ - write
http://www.php.net/manual/en/function.fputs.php
and once more try change
- Code: Select all
<?php
$file = "abc.txt";
$file_handle=fopen($file, "r+");
$now = date("y-m-d");
fputs($file_handle, $name."\n".$now."\n".$comment);
fclose($file_handle);
?>
at this:
- Code: Select all
<?php
$file = "abc.txt";
$file_handle=fopen($file, "r");
$now = date("y-m-d");
fputs($file_handle, $name."\n".$now."\n".$comment);
fclose($file_handle);
?>

