Hi,
When I attempt to open a file to write (using fopen("filename.txt","w")), I am unable to open the file.
I'm new to PHP, so here's my question: could this be due to settings on my server (business server, so changning it might be... fun) or is it probably something I'm doing wrong?
I was getting weird results with my main file, so I wrote a small test program:
<html>
<head>
<title>WriteFile Test</title>
</head>
<body>
<?
$fp = fopen("file.txt","w") or die("can't write file");
if (fwrite($fp,$var)) {print "written";}
else {print "not written";}
fclose($fp);
?>
</body>
</html>
And I get "can't write file"...
Any help would be appreciated.
Thanks.
Write to File
Moderator: General Moderators
c) Is the server platform WIndows/UNIX?
d) Please note in your code you reference 'file.txt' and in your question you reference 'filename.txt'.
e) Is the file in the same directory as the PHP script?
f) PHP Manual: fopen()
d) Please note in your code you reference 'file.txt' and in your question you reference 'filename.txt'.
e) Is the file in the same directory as the PHP script?
f) PHP Manual: fopen()