Jump to content
xisto Community
Sign in to follow this  
shadowx

Problem With Opening And Reading Files In Php access denied error using fopen etc...

Recommended Posts

Hi all

I'm having a problem when using php to read from a text file the error is this:

failed to open stream: Permission denied in /home/shadyx/public_html/index.php

And this obviously stops fread and fwrite from working. the code i used for this is...
$handle = fopen("ipstuffs/iplog.htm", "a");fwrite($handle, "date: $date <BR> $ip <BR>Referrer: $refer_url<BR><HR><BR>");fclose($handle);

It runs nicely on my xampp IDE so i dont think its the code, possibly a setting in the ini file but i do not know how to edit that ( if its even possible ) online. Can anyone shed light on this problem? in the file manager in the cpanel i have set permissions for user and group to all as i thought this could be the problem but it had no effect.

Please help <_<

Thanx

Share this post


Link to post
Share on other sites

have you set user, group, world permissions to a full "777"?and why print the html br tags and the hr tags to the file? maybe try comma seperated format?

Share this post


Link to post
Share on other sites

i have just set the directory public_html to 777 and the same error still. its odd as it is able to read from another file yet when writing to that file it gives the same error that access is denied. So it must be something with the write permissions but i cant think why.And i add the BR and HR tags because its a plain text file printed into the html content so is parsed as normal html and this way i can stop people posting things like html tags and js scritps etc... im just not advanced enough yet to use commas and such <_<***EDIT: I had to change the permissions for the individual files in question which i have now done and it now works perfectly. :lol: thanks for the help. Hope other people learn from my mistake because that was annoying!Thanx

Edited by shadowx (see edit history)

Share this post


Link to post
Share on other sites

Just setting the public_html directory to 777 does not necessarily work. Different FTP programs work in different ways for CHMOD, some apply the settings just to the folder, some to everything within it and some ask. Make sure you specifically set that file to permissions of 777.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.