PHP permission codes

Hello

This is my first time posting - ever - anywhere. Please be patient, I consider myself “embryonic” to the computer world. The problem for me is that a friend has asked me to maintain her website. Ha, silly me, thought I could do it. The opening page is a PHP one, and usually I have been able to get into the admin site and edit text, etc. Today for some reason I am receiving error codes such as

Warning: fopen(…/data/clinics.txt): failed to open stream: Permission denied in /var/www/html/php/clinicupdate.php on line 69

I tried to do some online research and I went into my ftp and checked on permission codes and they seem to be 755 mostly. On the VAR file it is zero and won’t allow me to change that, and I have no clue if that’s important or not.

I guess what I really want is to be able to email you the website and logon and have you look at it — since it’s probably easier for you in the long run. There were a series of error messages like:

Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/html/php/clinicupdate.php on line 70

You’re probably used to seeing it, but it scares the heck out of me! I have no idea why after being able to work on this PHP page for over a year that it would suddenly get nasty with me.

Thanks so much, sorry to be long winded.

Well, your root problem is that first error message, that means something went wrong opening the file. I don’t know how familiar you are with php/web stuff, so forgive me if I’m going to basic, but I’ll just start at the beginning.

fopen(…/data/clinics.txt)

The “…/” in the data path is a relative path. It means go up one folder from the folder where the calling program resides. Since the calling program is “/var/www/html/php/clinicupdate.php”, this means that you need to look for “/var/www/html/data/clinics.txt”.

This method is trying to open a file (I’m assuming for writing, but could be just for reading). What you need to do is go to your “/var/www/html/data” folder and look for the “clinics.txt” file. If you don’t find it there, then that’s your problem, it can no longer find the file where it expects it. If you find the file, check the permissions of the file and make sure that you have read/write permissions for everybody on that file.

This error could have popped up because a folder got renamed/moved/deleted on accident, but let me know if you find anything out.

In addition to what Monk is saying, PHP usually runs as a different ‘user’ than you do. Be sure it has the proper permissions on the file. Also, I’m not sure if this is just the script messing up or if it is like that in the script itself: [url=http]fopen()[url] requires a second argument.

Sponsor our Newsletter | Privacy Policy | Terms of Service