Jul 26, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > The Internet > Website Discussion

free web hosting

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

elrohir
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/

 

 

 


Reply

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

Reply

elrohir
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...

Reply

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

Reply

elrohir
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

Reply

ghostrider
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.

Reply

elrohir
Yeh, I asked them about it, and aftera couple attempts they fixed it biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. permissions in php fopen - 10.20 hr back. (1)
  2. php fopen error - 120.13 hr back. (2)
Similar Topics

Keywords : php, fopen, error, prob, permissions, php, fopen

  1. The True Story Of The Internet (without Error)
    video about the development of Internet (0)
  2. Forum Script Error
    (3)
    hey, im getting this error when im trying to view a message on my forum, QUOTE Parse error:
    syntax error, unexpected T_VARIABLE in /home/luki/public_html/forum/viewtopic.php on line 26 and
    this is what is on line 26 in that file.. i don't know waht's wrong with it. QUOTE
    LIMIT$start, ".$board_config ; and this is what it loks like all together... QUOTE
    define('IN_PHPBB', true); define('IN_CASHMOD', true); define('CM_VIEWTOPIC',
    true); LIMIT$start, ".$board_config ; $cm_viewtopic->generate_column....
  3. Http Error Messages
    Reference Material (0)
    QUOTE 100 Continue Only a part of the request has been received by the server, but as long
    as it has not been rejected, the client should continue with the request 101 Switching Protocols
    The server switches protocol 200 OK The request is OK 201 Created The request is complete,
    and a new resource is created 202 Accepted The request is accepted for processing, but the
    processing is not complete 203 Non-authoritative Information    204 No Content    205 Reset
    Content    206 Partial Content 300 Multiple Choices A link list. The user can....
  4. Gmail: 502 Server Error
    GMail: 502 Server Error (20)
    Hey The topic name says it all. Well I have been trying for the last half an hour to log into my
    GMail account, but it kept on occuring a Server 502 error. Just wondering if it is just me
    or....yeah. QUOTE Server Error The server encountered a temporary error and could not complete
    your request. Please try again in 30 seconds. Yep I have tried every minute..for the last half
    an hour...(The Time now is 12.13pm Australian Eastern Standard Time) ....
  5. Awesome 404 Error
    (9)
    404 rofl The link is a swf for a 404 (page not found) error, I thought it was pretty funny and
    thought I'd share it Edited as reported. ....
  6. I Have Ipb Error But It Doesn't Make Sense
    php programmers plz look (1)
    $lang = array ( 'settings_reptrack' => "Inform you if your reputation was
    changed?", //2.0.2 'm_blog' => "Community Blog", 'm_blog_ucp_main' => "Your
    Blog Settings", 'm_blog_cblocks' => "Content Blocks Settings", 'm_blog_aboutme' =>
    "About Me Settings", 'm_blog_your_blog' => "Your Blog", //2.0 //D2-My Main Page
    'mmp_title' => "My Main Page", 'mmp_current' => "My Current Main Page",
    'mmp_change' => "Change My Main Page", 'mmp_no_pages' => "There Currently Isn't
    Any Pages....
  7. !help! Error On Ipb Forums! Help!
    (3)
    http://www.hostjunkies.trap17.com/forums/i...php?showtopic=5 mysql! error! i dont know
    what happened? if you can help please post here....if u cant click link this is what it says QUOTE
    mySQL query error: SELECT p.*,     m.id,m.name,m.mgroup,m.email,m.joined,m.posts, m.last_visit,
    m.last_activity,m.login_anonymous,m.title,m.hide_email, m.warn_level, m.warn_lastwarn,    
    me.msnname,me.aim_name,me.icq_number,me.signature, me.website,me.yahoo,me.location,
    me.avatar_location, me.avatar_type, me.avatar_size,     pc.*     FROM trap17_ipbposts p       LEFT
    JOIN tr....
  8. Strange Error On My Site
    (2)
    i was getting a too many connections error when i attempted to acess my site. why was it doing this?....

    1. Looking for php, fopen, error, prob, permissions, php, fopen

Searching Video's for php, fopen, error, prob, permissions, php, fopen
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE