Weird Troubles Writing to File

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to use PHP to create a text file.  Simple right?  I've done
it before.  I don't know why it's not working now.  It's not rocket
science.  In general, I'd say I'm a PHP beginner, but with an
intermediate skill level in certain facets of the language.

  $thisFileName = 'test.txt';
  $fp = fopen($thisFileName, "w");
   $write = fputs($fp, "test");
  if (!file_exists($thisFileName))
   die("File does not exist.");

* This script is in the same directory as the text file.
* I am on a Windows server.
* The permissions for the folder I'm in, and the files, is 666
* I have tried using just the file name and also the full path.

I can modify that script to do a READ instead of a write, and set the
filename to a file that exists already.... it works just fine.  But
even if I leave the filename to a file that exists, and try the above
script to write over it... it won't work.

How can I find out what the problem is?  I'm not getting any PHP error
info on browser.  I guess they have debugging turned off.

Thanks for any help!


Re: Weird Troubles Writing to File

Jolly Green Giant wrote:
Quoted text here. Click to load it

Sorry, not sure what the problem is.

You should be able to turn error messages on with error_reporting(),


Another thing you could try is cut n paste the script in the php manual
for fwrite (its identical to fputs) as it checks for errors after each
step and it might tell you where the problem is.



Re: Weird Troubles Writing to File

Thank you!  That error_reporting changed the debugging so that it told
me that my file perms were wrong.  Perfect.  Thank you

Site Timeline