Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Fopen() Error..., got a prob with permissions in PHP with fopen() any help?
elrohir
post May 19 2006, 05:51 PM
Post #1


Premium Member
********

Group: Members
Posts: 165
Joined: 17-May 06
Member No.: 23,815



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:

CODE

    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/
Go to the top of the page
 
+Quote Post
jlhaslip
post May 19 2006, 11:48 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,910
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



try to alter the file's permissions to world write, ie: 777 using the chmod command.
Go to the top of the page
 
+Quote Post
elrohir
post May 20 2006, 12:17 PM
Post #3


Premium Member
********

Group: Members
Posts: 165
Joined: 17-May 06
Member No.: 23,815



returns the error

Warning: chmod(): Operation not permitted in /path/file.php on line X

as 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 tongue.gif ... We will se...

This post has been edited by elrohir: May 20 2006, 12:26 PM
Go to the top of the page
 
+Quote Post
Avalon
post May 20 2006, 02:50 PM
Post #4


Privileged Member
*********

Group: Members
Posts: 630
Joined: 12-August 05
From: Melbourne, Australia
Member No.: 10,624



I assmue you have declared the $file variable somewhere? e.g. $file = file.php Without this it will not work.

This post has been edited by Avalon: May 20 2006, 02:51 PM
Go to the top of the page
 
+Quote Post
elrohir
post May 20 2006, 02:54 PM
Post #5


Premium Member
********

Group: Members
Posts: 165
Joined: 17-May 06
Member No.: 23,815



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 tongue.gif
Go to the top of the page
 
+Quote Post
ghostrider
post Jun 13 2006, 01:12 AM
Post #6


Super Member
*********

Group: Members
Posts: 397
Joined: 9-June 06
From: Wisconsin
Member No.: 24,924



QUOTE
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.
Go to the top of the page
 
+Quote Post
elrohir
post Jun 13 2006, 02:31 PM
Post #7


Premium Member
********

Group: Members
Posts: 165
Joined: 17-May 06
Member No.: 23,815



Yeh, I asked them about it, and aftera couple attempts they fixed it biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. I Have Ipb Error But It Doesn't Make Sense(1)
  2. Awesome 404 Error(9)
  3. Gmail: 502 Server Error(22)
  4. Http Error Messages(0)
  5. Forum Script Error(3)
  6. The True Story Of The Internet (without Error)(0)


 



- Lo-Fi Version Time is now: 7th August 2008 - 11:36 PM