fopen file - help !!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pnog
Forum Newbie
Posts: 2
Joined: Thu Jun 19, 2008 7:24 pm

fopen file - help !!!

Post 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
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: fopen file - help !!!

Post 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.
pnog
Forum Newbie
Posts: 2
Joined: Thu Jun 19, 2008 7:24 pm

Re: fopen file - help !!!

Post 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
Post Reply