Click to See Complete Forum and Search --> : php wont write but will read text??


guyjusthere
08-04-2007, 09:25 PM
WHy wont my text file update?
this says that there is a connect error.. I have tried fwrite().. everything.. it all wont write to the file.. the only thing that works is if i read and echo...

THIS WORKS
<?php
$news = file("file.txt");
echo $news[0]. "<br>";
echo $news[1] . "<br>" . $news[2]
?>



But this doesn't???


<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>

Does this mean that my php server doesn't allow it?? b/ci have a huge forum on my site... www.106clan.org

NogDog
08-04-2007, 09:31 PM
It's most likely that the file permissions do not allow it. (Remember that your script is probably being run as a user other than your personal login account, so the file will likely need write access by all if you want your script to write to it.)

guyjusthere
08-04-2007, 09:34 PM
soo... do i have to add that on the top of the script to log in to the server?

NogDog
08-04-2007, 10:38 PM
No, you probably have to log on to your web host and change the file permissions, either via FTP or your web host's control panel application, or by connecting via telnet and changing permissions via the command line.