Page 1 of 2

fopen function

Posted: Mon Nov 19, 2007 9:43 am
by moleculo
Hi folks,

I'm trying to write a script that creates files as seen in this tutorial here:
http://www.vipercreations.com/tutorials ... 5&act=view

I keep getting
Warning: fopen(home/molin3/public_html/htm/HTPA2A153.htm) [function.fopen]: failed to open stream: No such file or directory in /home/molin3/public_html/htm/addfile.php

The directory I'm using is /home/molin3/public_html/htm/

Am I putting in the wrong path or is it possibly that the fopen function is disabled on my server. If so, How can I check and/or enable it?

Posted: Mon Nov 19, 2007 9:45 am
by feyd
The error suggest you aren't using the leading slash.

Posted: Mon Nov 19, 2007 9:51 am
by moleculo
Oops, I forgot to mention that I also tried with the leading slash.

I get this with the leading slash:
Warning: fopen(/home/molin3/public_html/htm/HTPA2A153.htm) [function.fopen]: failed to open stream: Permission denied in /home/molin3/public_html/htm/addfile.php

Posted: Mon Nov 19, 2007 9:57 am
by feyd
That error is due to the fact that PHP has not been given permission to read and/or write to the directory or file in question. CHMOD time.

Posted: Mon Nov 19, 2007 9:57 am
by RobertGonzalez
Permission denied usually means that means your web server doesn't have permission to view/open that file. What are the permissions on that directory/file?

Posted: Mon Nov 19, 2007 10:17 am
by moleculo
Everah wrote:Permission denied usually means that means your web server doesn't have permission to view/open that file. What are the permissions on that directory/file?
the public_html directory is set to 750. When I tried to change it, some problems were created where php was unable to read from the mysql database. I had to contact my webhost to get it restored, and I don't know what they did.

I created a subdirectory called "htm" and gave it permissions of 777, but I'm not sure if that's overriden by the public_html directory which is above it.

Anyways, I thought the chmod function in this script was supposed to adjust to the appropriate permissions.

Posted: Mon Nov 19, 2007 10:19 am
by moleculo
feyd wrote:That error is due to the fact that PHP has not been given permission to read and/or write to the directory or file in question. CHMOD time.
But there is a CHMOD in the script. Could you please take a look at the script in the link above and tell me if the CHMOD part is written correctly or needs adjustment?

Posted: Mon Nov 19, 2007 10:26 am
by RobertGonzalez
You don't want to chmod permissions on public_html, you want to do it on the directory that needs to be accessed and on that directory only. You typically do not do this programmatically, but through either the CLI with a chmod command or through an FTP client of some sort.

Posted: Mon Nov 19, 2007 10:34 am
by moleculo
Everah wrote:You don't want to chmod permissions on public_html, you want to do it on the directory that needs to be accessed and on that directory only. You typically do not do this programmatically, but through either the CLI with a chmod command or through an FTP client of some sort.
When I created the directory "htm" and gave it the 777 permissions, is this what you mean?

Are you saying running the same script using a CLI will work?

Posted: Mon Nov 19, 2007 10:54 am
by moleculo
Ok, I'm gonna try it with CLI.

I've never worked on CLI before. Do you recommend any package for installing it for windows?

How's ezpublish?
http://ez.no/ezpublish/documentation/in ... ge_php_cli

Posted: Mon Nov 19, 2007 11:10 am
by RobertGonzalez
No no, I mean if you have SSH and log in to your server at the command prompt. If you don't have SSH access, then use your FTP client to make a directory and set the directory to 777. That should do it.

Posted: Mon Nov 19, 2007 12:07 pm
by moleculo
Any recommendations for a CLI client?

I'm having trouble installing ezpublisher.

Posted: Mon Nov 19, 2007 12:12 pm
by RobertGonzalez
You don't need a CLI client. If you are connecting to your server through SSH use something like Putty if you are on Windows. Otherwise, use your terminal on Mac/*nix.

Posted: Mon Nov 19, 2007 12:27 pm
by moleculo
Everah wrote:You don't need a CLI client. If you are connecting to your server through SSH use something like Putty if you are on Windows. Otherwise, use your terminal on Mac/*nix.
I'm not using SSH. I'm connecting by FTP through dreamweaver. You think I should install putty instead?

Posted: Mon Nov 19, 2007 12:39 pm
by RobertGonzalez
No, I think you should right click on the folder in the FTP window using Dreamweaver. You don't need a CLI client at all for what you are doing. Use your FTP client in Dreamweaver.