Page 1 of 1

Permission denied

Posted: Mon Feb 26, 2007 1:51 am
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

Posted: Mon Feb 26, 2007 2:36 am
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

Posted: Mon Feb 26, 2007 3:09 am
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.

Posted: Mon Feb 26, 2007 4:37 am
by Kieran Huggins
sometimes you need to touch() the file first - don't know why, but it works!

Posted: Mon Feb 26, 2007 9:20 am
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'.

Posted: Mon Feb 26, 2007 10:41 am
by Adrianc333
Try CHMOD'ing the file to 0777

Posted: Mon Feb 26, 2007 11:13 am
by RobertGonzalez
Use arborint's suggestion. It is the safest.

Posted: Mon Feb 26, 2007 9:44 pm
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.. :)

Posted: Tue Feb 27, 2007 2:00 am
by dibyendrah
Never change mode to 0777 unless you need it ! Many web server will not read page which have mode to 777.

Posted: Tue Feb 27, 2007 11:59 am
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.