Page 1 of 1

fopen file - help !!!

Posted: Thu Jun 19, 2008 7:27 pm
by pnog
Hi,

I'm trying to write a file, using this code:

$myfile = "c:\wamp\www\testes.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);

I'm using WAMP on Windows Vista, I have total permissions to everybody on c:\wamp\www

But I can't write the file and get "can't open file".

Thanks for your help.

Pedro

Re: fopen file - help !!!

Posted: Thu Jun 19, 2008 11:06 pm
by WebbieDave
Change:

Code: Select all

$myfile = "c:\wamp\www\testes.txt";
To:

Code: Select all

$myfile = 'c:\wamp\www\testes.txt';
Note I've only replaced the double-quotes with single-quotes. The \t is a special character (tab) that will be escaped in a double-quoted string.

Re: fopen file - help !!!

Posted: Fri Jun 20, 2008 3:55 am
by pnog
Thanks for your tip, and I think that was one of the problems, but it still gives-me the same msg.
"can't open file"

This is my first time using php on windows environment, and has I told, I've put "full control" permissions to everyone, but I want to ask if someone knows the user that is used in vista by apache.

Thanks.
Pedro