Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 02-08-2004, 09:25 PM
Daniel Craig Daniel Craig is offline
Hatchling Croc
 
Join Date: Feb 2004
Posts: 2
Default

Hi folks,

I'm running a php script that should create a new text file every time someone submits a form. The php feedback on the page works fine, but at the bottom of the page (where the fopen() function is) I get this message.

Warning: fopen(results/lksd.txt): failed to open stream: Permission denied in /home/daacraig/public_html/indiana/classes/r641/www/quiz2/quizaction.php4 on line 150
Cannot open the file


The code generating this error is

$handle=fopen("results/$studentemail.txt", "a");

Any help would be appreciated. I'm a relative php beginner, but more importantly this is the first time I've tried running scripts on this host.

Thanks,
Dan
Reply With Quote
  #2  
Old 02-08-2004, 11:34 PM
baqua baqua is offline
Hatchling Croc
 
Join Date: Dec 2003
Posts: 17
Default

This looks like it may be a filesystem permissions problem. Using the file manager that can be launched from the cpanel, check the permissions of both the directory 'results' and of the file 'lksd.txt'. It is most likely the lack of write permissions in the results directory.

Try (but check the FAQ and admin before making a habit of) setting write permissions on the directory and file in question for all (owner, group and everyone). If security is set up properly, you should only need to do group, so try scaling back on giving world permission if the above works.


--baqua
Reply With Quote
  #3  
Old 02-09-2004, 10:15 AM
Daniel Craig Daniel Craig is offline
Hatchling Croc
 
Join Date: Feb 2004
Posts: 2
Default

Thanks for the advice baqua. Unfortunately, I've even tried setting all permissions at 777 and still no luck. I also attempted to load a static text file and write to it, but still the same error message.

Dan
Reply With Quote
  #4  
Old 04-09-2004, 12:15 PM
FragMaster B FragMaster B is offline
Hatchling Croc
 
Join Date: Jan 2004
Posts: 32
Default

I'm having a similar problem. Anyone seen a resolution to this? My script which does "fopen" calls as well as "unlink" calls is getting all kinds of Permission denied errors. Even when dirs are set to 777. Script works fine on my local IIS...
Reply With Quote
  #5  
Old 04-12-2004, 09:05 AM
FragMaster B FragMaster B is offline
Hatchling Croc
 
Join Date: Jan 2004
Posts: 32
Default

Well, I solved this: When I set my folder permission to 777. I assumed that chmod would propogate down to all sub directories. For some reason it did not. When I applied 777 to the exact folder containing the file I was trying to open/write, everything worked...

Why is chmod not recursive?
Reply With Quote
  #6  
Old 04-13-2004, 11:26 AM
joey_ramones joey_ramones is offline
Hatchling Croc
 
Join Date: Apr 2004
Posts: 9
Default

i think it is 2 different thing, chmod just folder and chmod folder with all containing files in it. this must be refer to the script manual which one you should chmod, just folder or folder with all in it. by default, it only chmod the folder. that's why it is not propogated automatically.
__________________
Ramones - It's Alive!
Reply With Quote
  #7  
Old 05-07-2004, 03:41 PM
97transam's Avatar
97transam 97transam is offline
Hatchling Croc
 
Join Date: Apr 2004
Location: Chalfont, Pa
Posts: 49
Default

I had similiar problems where I had a form that allowed endusers to browse their PC and upload image files to a MySQL DB. Meaning no insult here, in addition to chmod 777 for the directory, I had set the following variables (I change the dir and filename to suit your example);

$path = "/home/username/public_html/results/";
$filename="lksd.txt";

username would be the accounts cpanel name.

Then maybe fopen($path$filename) will hopefully work for you?
Just a guess on my part.

--ron
__________________
97 Trans Am
Reply With Quote
  #8  
Old 03-06-2006, 07:22 AM
Unregistered
HostGator Guest
 
Posts: n/a
Default Re: php permission denied problem

I'm getting 'Permission Denied' at my fopen line, while trying to creating a new file for writing, in a directory which has 777 permissions.

I wrote a script to run some tests, and check a few things (e.g. is php safe mode on?) See here: http://www.archivaty.net/forums/about54278.html#300599

...others might find that useful, but at the end of the day it didn't help me. I still no idea why it's giving 'Permission denied'! You folks know any config setting I'm missing?
Reply With Quote
  #9  
Old 03-06-2006, 08:41 AM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,067
Default Re: php permission denied problem

Quote:
Originally Posted by Unregistered
I'm getting 'Permission Denied' at my fopen line, while trying to creating a new file for writing, in a directory which has 777 permissions.

I wrote a script to run some tests, and check a few things (e.g. is php safe mode on?) See here: http://www.archivaty.net/forums/about54278.html#300599

...others might find that useful, but at the end of the day it didn't help me. I still no idea why it's giving 'Permission denied'! You folks know any config setting I'm missing?
Post the code you are using, if it is anything like the code in the first post, it will NEVER work. The permission denied error can be caused by things other than permissions, like trying to write a file that can't be written to, like in the above example.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #10  
Old 12-04-2006, 08:35 AM
rahul
HostGator Guest
 
Posts: n/a
Default Re: php permission denied problem

thank's
i've change the permission of my folder and the code run and the new file creats
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 04:36 PM.

 
Forum SEO by Zoints