Hi
I have an issue on my Fedora Core 4 installation where PHP scripts can't write to text files.
As an example, I get the following in Apache error logs:
PHP Warning: fwrite(): supplied argument is not a valid stream resource...
PHP Warning: fclose(): supplied argument is not a valid stream resource...
Apache is running as user "apache", with the files in question having been chown'd to apache & chmod'd to 777.
SELinux is disabled.
"Safe mode" in php.ini is set to off, & it's configuration hasn't been altered since installation.
Running Apache 2.0.54-10.2 & PHP 5.0.4-10.4.
Can someone please help me with this one?
Thanks
Ashley
PHP & Writing to Files
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
The code is from a tutorial (i'm a php newbie)...
I've had similar issues with writing to files when using phpBB & Subdreamer also.
Code: Select all
$fp = fopen("$DOCUMENT_ROOT/../php_files/orders.txt", 'ab');
fwrite($fp, $outputstring, strlen($outputstring));
fclose($fp);- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Sorry, I should have mentioned that at the top of the file I have:
Code: Select all
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];