Opening a file question
Question about opening and writing to a file.. I've looked at the PHP manual online and saw how to use fopen and to test if the file is writable. I created a test file for writing and just want to write some dummy lines in there at first.
When I first ran is_writable($filename) it said it was NOT writable, so I changed permissions on the file to allow "others" to write to the file. This is just on my computer, will I have to make the same permission change when I upload to the remote server? It takes any outside access not by owner but as an "other"?
Now I've got a writable file which won't open. My code is as follows:
and I get an error message of Warning: fopen(testwrite.txt): failed to open stream: File exists in .../Sites/TestWrite.php on line 7 which comes up before my "opening failed" line. Line 7 is actually a blank line so I know it's not that.
The site said that safe_mode and open_basedir might have something to do with it. Can anyone tell me approximately where (I'm running OS 10.3 PHP server locally) I might find these files to edit the dir path? And if it's not those, what IS causing the error?
When I first ran is_writable($filename) it said it was NOT writable, so I changed permissions on the file to allow "others" to write to the file. This is just on my computer, will I have to make the same permission change when I upload to the remote server? It takes any outside access not by owner but as an "other"?
Now I've got a writable file which won't open. My code is as follows:
$filename = "testwrite.txt";
$file = fopen($filename, "x");
if (!$file)
{
echo "Opening file failed";
}
else
{
echo "
File open";
}
and I get an error message of Warning: fopen(testwrite.txt): failed to open stream: File exists in .../Sites/TestWrite.php on line 7 which comes up before my "opening failed" line. Line 7 is actually a blank line so I know it's not that.
The site said that safe_mode and open_basedir might have something to do with it. Can anyone tell me approximately where (I'm running OS 10.3 PHP server locally) I might find these files to edit the dir path? And if it's not those, what IS causing the error?
