I recently changed Web host providers and a game I wrote is now not working (it used to on my old provder's server).
When my script tries to write a file for a member who is playing, I get an "access denied" error. Here's the offending code:
$fp=fopen("$DOCUMENT_ROOT/mygame/players/$playerfile", "w");
flock($fp, 2); //lock file for writing
fwrite($fp, $today);
flock($fp, 3); // release write lock
fclose($fp); // close date file after writing member number
If a player has not played before, and the file does not exist for them, then it is created. All that the file contains is today's date (for a check to make sure they only can play once a day). If the file does not exist, the script will create it - that part works fine.
However, if the file does exist, the script is supposed to open the file for writing and overwrite with a new (today's) date. But in this case, where the file exisits and the script is trying to open it to overwrite a new date, I get an "access denied file...." error" (I have to remove the "@" to see this error). I also of course get file hanler errors on the flock, fwrite and fclose commands (since $fp was not opened).
I suspect this problem has something to do with who PhP is configured on my new server, and not seeing my script as the "owner" when it tries to open an existing file. Any ideas what might be causing this and what could be dome about it?
Thanks,
Basil