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

Cannot write to a text file in PHP

Reply to Message Icon

Original Message
Name: Martin691
Date: February 9, 2005 at 08:43:56 Pacific
Subject: Cannot write to a text file in PHP
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.


Report Offensive Message For Removal

Response Number 1
Name: juvi
Date: February 9, 2005 at 16:33:52 Pacific
Subject: Cannot write to a text file in PHP
Reply: (edit)

Is orders.txt itself changed to 777


Report Offensive Follow Up For Removal

Response Number 2
Name: Jamie_McCoy
Date: February 10, 2005 at 00:50:04 Pacific
Subject: Cannot write to a text file in PHP
Reply: (edit)

and the actually folder its in

that will fix it

Jaydiocity.co.uk


Report Offensive Follow Up For Removal

Response Number 3
Name: Martin691
Date: February 10, 2005 at 13:44:26 Pacific
Subject: Cannot write to a text file in PHP
Reply: (edit)

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.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Cannot write to a text file in PHP

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software