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
bebensiganteng
Forum Newbie
Posts: 23 Joined: Wed Jan 03, 2007 6:03 am
Location: UAE
Post
by bebensiganteng » Mon Feb 26, 2007 1:51 am
Hi guys,
Please help..
this is the code;
Code: Select all
function record_message($sDate) {
$handle = fopen("ResultsMaxGraham26022007.txt", "a");
fputs($handle, "Input Date: ".$sDate."\r\n");
fputs($handle, "Name: ".$_POST['name']."\r\n");
fputs($handle, "Email: ".$_POST['email']."\r\n");
fputs($handle, "Answer: ".$_POST['soal']."\r\n");
if($_POST['soal'] == 'Montreal') {
fputs($handle, "Status: CORRECT\r\n\n");
} else {
fputs($handle, "Status: INCORRECT\r\n\n");
}
fclose($handle);
}
and this the problem
Code: Select all
Warning: fopen(ResultsMaxGraham26022007.txt): failed to open stream: Permission denied in /www/htdocs/ultimcom/maxgraham/index.php on line
Thanks in advance
bebensiganteng
Forum Newbie
Posts: 23 Joined: Wed Jan 03, 2007 6:03 am
Location: UAE
Post
by bebensiganteng » Mon Feb 26, 2007 2:36 am
Addition.
Do you guys know anyway to get around this? can this restriction be disabled from the php script?
Ok Thanks again in advance
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Mon Feb 26, 2007 3:09 am
You edited/uploaded the file as your user, but it must be readable by the user that the webserver runs as. Change permissions or owner/group.
(#10850)
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Mon Feb 26, 2007 4:37 am
sometimes you need to touch() the file first - don't know why, but it works!
visitor-Q
Forum Commoner
Posts: 72 Joined: Mon Feb 05, 2007 1:40 am
Post
by visitor-Q » Mon Feb 26, 2007 9:20 am
bebensiganteng wrote: Addition.
Do you guys know anyway to get around this? can this restriction be disabled from the php script?
Ok Thanks again in advance
are you using a windows server or a linux server? if it's windows, you can locate the file and right click it, then click properties. go to the security tab, and set permissions. don't forget you also need to change permissions to the folder itself, as well. the same goes for linux, except you can run the command 'chmod'.
Adrianc333
Forum Newbie
Posts: 14 Joined: Sat Feb 17, 2007 5:44 am
Location: South Yorkshire, UK
Post
by Adrianc333 » Mon Feb 26, 2007 10:41 am
Try CHMOD'ing the file to 0777
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Mon Feb 26, 2007 11:13 am
Use arborint's suggestion. It is the safest.
bebensiganteng
Forum Newbie
Posts: 23 Joined: Wed Jan 03, 2007 6:03 am
Location: UAE
Post
by bebensiganteng » Mon Feb 26, 2007 9:44 pm
You edited/uploaded the file as your user, but it must be readable by the user that the webserver runs as. Change permissions or owner/group.
Could you explain in more detail please, I'm just a beginner..
dibyendrah
Forum Contributor
Posts: 491 Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:
Post
by dibyendrah » Tue Feb 27, 2007 2:00 am
Never change mode to 0777 unless you need it ! Many web server will not read page which have mode to 777.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Tue Feb 27, 2007 11:59 am
bebensiganteng wrote: You edited/uploaded the file as your user, but it must be readable by the user that the webserver runs as. Change permissions or owner/group.
Could you explain in more detail please, I'm just a beginner..
The user of the application is not the same user as the server. On an apache server, the server usually runs as apache as part of the apache group.