Computing.Net > Forums > Web Development > Cannot write to a text file in PHP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Cannot write to a text file in PHP

Reply to Message Icon

Name: Martin691
Date: February 9, 2005 at 08:43:56 Pacific
OS: Linux Fedora Core 3
CPU/Ram: 512Mb
Comment:

I am trying to write to a directory using PHP5.
The commands I am using are :
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", "ab");
$fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", "w");
$fp = fopen("orders.txt", "w");

The top one of the 3 is straight out of the book. The scripts I am using are out of the “PHP and MySQL Web Development” book by Welling Thomson, so the code is all good.

The message I got is as follows:

Warning: fopen(/var/www/html/../orders/orders.txt) [function.fopen]: failed to open stream: Permission denied in /var/www/html/processorder.php on line 129

I tried to write to other directories and that failed too, the directories concerned had read and write permissions enabled for everyone.
I checked the value of $DOCUMENT_ROOT and it is as I expected i.e.:
/var/www/html/../orders/orders.txt

/var/www/orders is a writeable directory for everyone

Do you know why I cannot write to this directory, I guess I have a config problem somewhere, but I have no idea.



Sponsored Link
Ads by Google

Response Number 1
Name: juvi
Date: February 9, 2005 at 16:33:52 Pacific
Reply:

Is orders.txt itself changed to 777


0

Response Number 2
Name: Jamie_McCoy
Date: February 10, 2005 at 00:50:04 Pacific
Reply:

and the actually folder its in

that will fix it

Jaydiocity.co.uk


0

Response Number 3
Name: Martin691
Date: February 10, 2005 at 13:44:26 Pacific
Reply:

Thanks, but this does not help. The files and the directories are all read and writeable.
Any other suggestions?
Orders.txt is 666, I changed it to 777, but it didn't help as expected.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Cannot write to a text file in PHP

form action to text file www.computing.net/answers/webdevel/form-action-to-text-file/2516.html

Link in PHP www.computing.net/answers/webdevel/link-in-php/190.html

check an app is running from a page www.computing.net/answers/webdevel/check-an-app-is-running-from-a-page/975.html