fopen function

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

moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

fopen function

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The error suggest you aren't using the leading slash.
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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.
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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?
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post by moleculo »

Any recommendations for a CLI client?

I'm having trouble installing ezpublisher.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
moleculo
Forum Newbie
Posts: 18
Joined: Thu Nov 15, 2007 9:05 am

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

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