writing to file, host problem ? plz help

General discussions related to php

Moderators: macek, egami, gesf

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

writing to file, host problem ? plz help

Postby scribeke » Sat Sep 28, 2002 2:22 am

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

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sat Sep 28, 2002 2:24 am

oh, don't pay attention to the line's being incorrect, I cutted the comments so now it's shorter ...

Jay

Postby Jay » Sat Sep 28, 2002 2:42 am

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!

DoppyNL

Postby DoppyNL » Sat Sep 28, 2002 2:42 am

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

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sat Sep 28, 2002 3:30 am

ok thx you guy's it works !

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sat Sep 28, 2002 3:55 am

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

can they hack me more easily then or so ?

thx

scribeke

scribeke
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 28, 2002 2:18 am

Postby scribeke » Sun Sep 29, 2002 1:37 am

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


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest