php fopen function dies, though I have file permissions set to read and write
Posted
by
Matthew Robert Keable
on Stack Overflow
See other posts from Stack Overflow
or by Matthew Robert Keable
Published on 2011-01-03T07:01:25Z
Indexed on
2011/01/03
7:53 UTC
Read the original article
Hit count: 301
I'm following a tutorial on php, and am having difficulty getting this to work. I set the appropriate directory permissions to read and write, but every time I run this, I get the die string.
The code is:
$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
As far as my basic understanding goes, if "testFile.txt" does not exist, fopen should create that file (I have basic knowledge of Python, and remember this same principle in that language). But it...it doesn't. Even if I create the aforementioned file, and put it up, that line of code still returns a die string.
My hosting account does not give me permission to execute. Is this a problem?
My server runs on Windows. I am using Dreamweaver CS5, on OSX 10.5.8.
I've done some searching on this, and see other people having similar issues - but none of them keyed to exactly my range of problems. Being that I'm a beginner, I feel that it might be something I'm overlooking.
Thanks!!
© Stack Overflow or respective owner