Jump to content
xisto Community
elrohir

Php Fopen() Error... got a prob with permissions in PHP with fopen() any help?

Recommended Posts

I had a script that was working just fine untill yesterday, when something freaked out with an fopen() I used in a login process (to add the user to the active users list). I think my host must have upgraded version and has not changed the permissions in php.ini to allow normal users to access such simple functions. The code I am using is really as basic as you can get:

	if (!file_exists($file)){								  		$fh = fopen($file, 'w') or die("can't open file");				$write = $username.':'.$remote;		fwrite($fh, $write);				fclose($fh);	}

it returns:

-
Warning: fopen(file.php): failed to open stream: Permission denied in /path/file.txt on line X

Warning: fwrite(): supplied argument is not a valid stream resource in /path/file.txt on line X

Warning: fclose(): supplied argument is not a valid stream resource in /path/file.txt on line X
-

Any ideas how to get round this? I do not have all that much experience with other methods - only ever needed 'w' - but it worked before.

Thanks in advance
/elrohir/

Share this post


Link to post
Share on other sites

try to alter the file's permissions to world write, ie: 777 using the chmod command.

Share this post


Link to post
Share on other sites

returns the error Warning: chmod(): Operation not permitted in /path/file.php on line Xas well as the previous errors... I have contacted the support - hopes up high - as it I do not seem to have any permissions whatsoever, which really is freaking me out :) ... We will se...

Edited by elrohir (see edit history)

Share this post


Link to post
Share on other sites

well, yeah...

As I said, I did not change the source, and suddenly it started giving funky error messages... I think I would have figured out if I had not set $file...

 

but thanks for checking :)

Share this post


Link to post
Share on other sites

Warning: fopen(file.php): failed to open stream: Permission denied in /path/file.txt on line X
Warning: fwrite(): supplied argument is not a valid stream resource in /path/file.txt on line X

Warning: fclose(): supplied argument is not a valid stream resource in /path/file.txt on line X


I think the best thing you can do is talk to your host about file permissions, I had to do that with my last host and he did it write a way. Once your file permissions are solved then all 3 errors should go away.

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

×
×
  • 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.