$fd = fopen("$books_file_name", "w");
$bookcount = array ("'$refbook|0'i");
$bookcountnew = array ("$refbook|1");
$newfile = preg_replace ($bookcount, $bookcountnew, $fd);
fputs = ($fd, $newfile);
fclose($fd);
$refbook is defined by a form
$books_file_name is the local path to the file books.txt, in which I want to replace any instances of $refbook|0 with $refbook|1
To do this, I write the file to $fd, I then to a preg_replace to search and replace for instances of $refbook|0. I then write the $newfile back to $fd and close the file.
What am I doing wrong? The file simply erases itself (without the fputs) and with the fputs I get a parse error. Any ideas?
creator.genesis