writing to file, host problem ? plz help

A

Anonymous

Guest
Hi, I tried writing to a file in php using the following code:

<?php
$file_name = "test.txt";
$file_pointer = fopen($file_name, "w");
fwrite($file_pointer, "what you wanna write");
fclose($file_pointer);
print "data written to file successfuly";
?>

but I keep getting an error message being:

Warning: fopen("test.txt", "w") - Permission denied in /home/scribeke/public_html/testfile/filewritetest.php on line 6

Warning: fwrite(): supplied argument is not a valid File-Handle resource in /home/scribeke/public_html/testfile/filewritetest.php on line 11

Warning: fclose(): supplied argument is not a valid File-Handle resource in /home/scribeke/public_html/testfile/filewritetest.php on line 15
data written to file successfuly

I used to be able to write to a file on this host without a problem a while ago, but now I get this, is it a script error or a host error, I don't know, I hope you guy's can tell me !

thx

scribeke
 
oh, don't pay attention to the line's being incorrect, I cutted the comments so now it's shorter ...
 
The first problem is that Permission is denied to open the file! This probably means the file permissions are incorrect, CHMOD it to 755 and try again.

Until that's sorted, the rest won't work!
 
You don't have permission to write to the file.
check the permissions of the files on you're webserver.

They probably changed some server settings since you last used the script.

If the file doesn't exist you will need create rights.
If the file exists you will need to be able to write to the file.

Greetz Daan
 
little question : is it bad to chmod all my html files to 766 ?

can they hack me more easily then or so ?

thx

scribeke
 
or why else is this chmod thing good for, why don't they put everything on 777 ?
 
Back
Top