hi everyone this is a really simple issue..(I hope)
I guess appending is out of the question, its more like prepending without overwriting any of the existing contents. r+ seems to overwrite bits but starts writing at the right place, the beginning of the file.
I have tried as best as I can to find an answer online .. ironically the only place I havent been able to visit is php.net! - its refusing my connection??
Im not really keen on any complicated methods of doing this..like reversing arrays and stuff. I tried them to no avail..
there must be a simple way that I have overlooked.
Ive tried all the switches.. a+ r+ w+ and the rewind function too,
any suggestions/code corrections would be much appreciated..
Code: Select all
<?php
@extract($_POST);
if(is_writable('news.txt'))
{
$fp = fopen('news.txt','r+');
$content = "\n$entrydate\n$entrymsg";
fseek($fp, 0, SEEK_SET); // not sure what the seek set means or that 0
//assuming that this puts the pointer at byte 0 or something?
//fwrite($fp,$content); // thought it might have issues with this.
fputs ($fp, "\n$entrydate\n$entrymsg");
fclose($fp);
echo'Successfully written entry';
}
else
{
echo'File is not writable';
}
?>cheers
-i
_________