I have been using a long script to overcome a problem I have been having. Here is the long version.
Code: Select all
// get old
$fp = fopen("$filename","r");
$old = fread($fp, filesize ($filename));
fclose($fp);
// kill file, write new then old
$fp = fopen($filename,"w");
fputs($fp,"$new $old");
fclose($fp);
This will save all the current data, and write the new info to the first line, and everything under it.
Seems the simple way to do this would be
Code: Select all
$fp = fopen($filename, "r+");
fputs($fp, $new);
fclose($fp);
But that does not work. PHP.net says the "r+" tag keeps the data, and puts the fp at the beginning of the file. In practice, though, it will post the new info once, then from that point on, it will post only part of the $new variable, or cut existing data. I've got no friggin idea what is going on with this. Can someone shed some light? php.net says this should work.
thanks
-seg