error message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gotcha
Forum Newbie
Posts: 2
Joined: Thu Oct 10, 2002 9:38 am

error message

Post 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------------------------------------------
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

Post 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.
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post 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)
gotcha
Forum Newbie
Posts: 2
Joined: Thu Oct 10, 2002 9:38 am

Post 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
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

A bit on how to calculate the values for chmod():
http://www.niche-associates.com/samples ... 404c_1.htm

Mac
Post Reply