Page 1 of 1

Please, Help Me!

Posted: Thu Feb 12, 2009 11:47 am
by granite
Hey there guys,

I'm trying to open a file which is in localhost, but I receive this error message:
Warning: fopen(newsletter/smtp.txt) [function.fopen]: failed to open stream: Permission denied in /home/arcamani/public_html/admin/smtp_newsletter.php on line 13

Warning: fwrite(): supplied argument is not a valid stream resource in /home/arcamani/public_html/admin/smtp_newsletter.php on line 14

Warning: fclose(): supplied argument is not a valid stream resource in /home/arcamani/public_html/admin/smtp_newsletter.php on line 15
The code pointed by the message:

Code: Select all

$open = fopen("newsletter/smtp.txt","w");
$gravar = fwrite($open,$mens);
fclose($open);
Oh, and there's not a "/home/arcamani/public_html/admin/" folder.

Can someone help me, please?

Thank you.

Re: Please, Help Me!

Posted: Thu Feb 12, 2009 12:44 pm
by sparrrow
Hard to tell not knowing your web server and OS. Could be file permissions. Try adding chmod("smtp.txt", 0777); on the line before you open the file. Also try creating/moving the file to the same directory as the PHP code temporarily to rule out the paths issue, and see if it works.

Re: Please, Help Me!

Posted: Thu Feb 12, 2009 12:57 pm
by granite
Tried what you said but just received an addicional warning.
Warning: chmod() [function.chmod]: No such file or directory in /home/arcamani/public_html/admin/smtp_newsletter.php on line 13
The OS I'm working on is Windows XP SP2, but the local server's OS is Windows Server 2003.
And I had already set permissions to 777 for the file "smtp.txt" and "newsletter/" directory.

Re: Please, Help Me!

Posted: Thu Feb 12, 2009 1:08 pm
by sparrrow
chmod is a unix command so that's why it won't work, but if you are certain of the file permissions then skip that anyway. Try adding "/" before the folder name? Try moving the file to the same directory as the code and remove the directory reference? Try opening the file as read only and see if you can read the contents? Sorry if this isn't much help, but I know there are several quirks between php running on Windows VS Linux, and IIS Vs Apache. The advice I'm trying to give is that a helpful approach to debugging is to simplify simplify simplify. Then less things you have going on, the less things you know are causing the issues.