...

View Full Version : Problem with writing to file.



vern
07-27-2005, 03:56 AM
The following code appends to file successfully and works perfectly.



$handle = fopen("recent.txt", 'a');
fwrite($handle, $add);
fclose($handle);


However ... this code doesn't seem to write to the file. The only different is that I want this code to set the pointer at the beginning of the file instead of the end. Anybody have any clues to what is going on?



$handle = fopen("recent.txt", 'r+');
fwrite($handle, $add);
fclose($handle);

nikkiH
07-27-2005, 03:29 PM
File might be locked.
Check.

http://us3.php.net/manual/en/function.fopen.php#37553

vern
07-28-2005, 06:38 PM
Apparently I had to read out the contents and then append to the stream. Got it to work now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum