Forum Moderators: coopster
if ($add=="y"[smilestopper])
{
$date=date("D-M-j"[smilestopper]);
$name=$_POST['name'];
$comment=$_POST['comment'];
$post="<small>$date</small> - <b>$name</b>: <i>$comment</i>";
$fp = fopen("post.txt", "a"[smilestopper]);
fwrite($fp, $post ."<br><br>"[smilestopper]);
} else {
$fp = fopen("post.txt", "r"[smilestopper]);
while (!feof($fp)) {
$buffer = fgets($fp);
echo stripslashes("$buffer"[smilestopper]);
}
fclose($fp);
}
?>
And I wanted to alter it so that new comments would go at the top of the file so I changed the "a" to "r+", but that overwrote weirdly like part of the file would remain but it would overwrite part of it. Then I tried adding rewind($fp); and fseek($fp,0); and still did the same thing.
Anyone have any suggestions?
Thanks,
ryanc
How many comments might there be? Could you read in the entire file as strings and then reverse them in the php?