Page 1 of 1

error message

Posted: Thu Oct 10, 2002 9:38 am
by gotcha
hi there

with regard to a php file that i have, i am getting error messages when i browse to the file, if any1 can, please check it out for me. below is the errors i am getting when browsing to the file, i attached the .php file as well, also just to let you know , i do have a file cookie.txt on the same directory the .php file is.

regards

Warning: fopen("cookie.txt","a") - Permission denied in /var/www/html/cookie.php on line 2

Warning: Supplied argument is not a valid File-Handle resource in /var/www/html/cookie.php on line 3

Warning: Supplied argument is not a valid File-Handle resource in /var/www/html/cookie.php on line 4
Message Not Found!


--------------------------------------cookie.php--------------------------------

<?php
$fp = fopen("cookie.txt","a");
fputs($fp, $cookie);
fclose($fp);
print "Message Not Found!"; /*this is so the admin doesnt get scared. and thinks its some bug.*/
?>

--------------------------------------eof------------------------------------------

Posted: Thu Oct 10, 2002 9:40 am
by twigletmac
It is telling you that you do not have the correct permissions to access the file - what are the file's permissions?

Mac

Posted: Thu Oct 10, 2002 9:42 am
by Takuma
Hehehe, go to your FTP program and change the CHMOD of the file to something like 777. Normaly this can be accessed by right-clicking the file and the selecting property -> and should be a CHMOD.

Posted: Thu Oct 10, 2002 9:51 am
by twigletmac
You don't need to give full permissions though, 755 should be enough to write to a file shouldn't it? You can also set file permissions using PHP:
http://www.php.net/manual/en/function.chmod.php

Mac

Posted: Thu Oct 10, 2002 10:55 am
by rev
It's more than likely a permission issue as pointed out by twigletmac and Takuma.

Is this file only going to be the property and responsibility of the web server? The reason I ask is because chown'ing the file over to the web server user may be your best bet instead of making a file world readable/writable.

twigletmac suggested using chmod() within your script. This may or may not work... The same permission restrictions not allowing fopen() to access the file will more than likely restrict your ability to chmod() the file to accectable access privileges.

Posted: Thu Oct 10, 2002 10:55 am
by gite_ashish
hi,

you can give the file permission like 644 to the file, provided that the file is owned by the web server user (it's a configurable parameter, default is nobody)

Posted: Fri Oct 11, 2002 2:12 am
by gotcha
thanks people, it was to do with permissions chmod to 777 and it works, thanks for the help. maybe i should look at the error messages more carefully before posting :-)

regards

Posted: Fri Oct 11, 2002 5:59 am
by Coco
is there anywhere that shows what all the different permissions are?
i know that 777 is full read write, but its not exactly a secure mode... what do i change it back to etc etc

Posted: Fri Oct 11, 2002 6:02 am
by twigletmac
A bit on how to calculate the values for chmod():
http://www.niche-associates.com/samples ... 404c_1.htm

Mac