Permission denied

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
bebensiganteng
Forum Newbie
Posts: 23
Joined: Wed Jan 03, 2007 6:03 am
Location: UAE

Permission denied

Post by bebensiganteng »

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 »

Addition.

Do you guys know anyway to get around this? can this restriction be disabled from the php script?

Ok Thanks again in advance
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

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)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

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 »

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 »

Try CHMOD'ing the file to 0777
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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 »

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.. :)
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Never change mode to 0777 unless you need it ! Many web server will not read page which have mode to 777.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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.
Post Reply