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!
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
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.
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.
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.