May 12, 2008

Fopen Errors :( - grrr, i'm angry :(

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Fopen Errors :( - grrr, i'm angry :(

tracdoor
Okay, i've made a very, very simple PHP counter for my site, i've set up all the permissions and everything (triple checked permissions are right);

CODE
<?php
$hits = file_get_contents("/home/tracdoor/public_html/hitcounter.txt");
$hits = $hits + 1;
  
$handle = fopen("hitcounter.txt", "w");
fwrite($handle, $hits);
fclose($handle);

print $hits;

?>


Now that works fine on my homepage, or any page in the /public_html/ directory, but if i include that in one of my pages:
CODE
There have been <?php include ("/home/tracdoor/public_html/counter.php"); ?> hits.


It says:

QUOTE
Warning: fopen(hitcounter.txt) [function.fopen]: failed to open stream: Permission denied in /home/tracdoor/public_html/counter.php on line 5


Can anyone find a way around this? or am i stuck?

 

 

 


Reply

jlhaslip
Exactly what permissions does the file have? 777?
And are all of the files contained in the public_html folder?

Reply

tracdoor
Yep, all the files are in public_html, and both the counter.php and hitcounter.txt are both 777, i'm just wondering whether there might be an fopen restriction, and with my limited knowledge of PHP, the only compromise i can see is adding both the files (counter.php and hitcounter.txt) into every directory, which i don't really want to do sad.gif

Reply

truefusion
I think it may have to do with the fact that open_basedir is enabled in Trap17. I'm not entirely sure why this is happening to you, since fopen works for me, but try changing the file path from "hitcounter.txt" to "./hitcounter.txt".

Reply

tracdoor
No, that didn't work, is there anyway around it? or am i just stuck?

Reply

truefusion
Try making a temporary empty folder in public_html, and copy "hitcounter.txt" and "counter.php" into that folder. Then modify "counter.php" located in that folder if need be, and run the file "counter.php" that's located in this newly created folder in your browser. Tell me if it still outputs that error.

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. fopen into a directory - 334.00 hr back.
  2. fopen http setcookie - 341.23 hr back.
  3. fopen restriction - 401.31 hr back.
  4. fopen 0x00000000 "w" - 668.94 hr back.
Similar Topics

Keywords : fopen, errors, grrr, im, angry,

  1. New Found Php Coding Errors
    I always thought these worked, but suddenly they no longer do?! (5)
  2. Header Redirect Errors
    (5)
    Hi, I am using the header function to redirect after the processing of the form. I have to specify
    a internal link using '#link'. This works in Firefox and opera. But in Internet Explorer
    internal linking when done from a redirect is not working for somewhat reasons. e.g.
    header("Location: http://www.example.com/index.php#link"); this works in Firefox and Opera but
    not in Internet Explorer . IE just accepts 'http://www.example.com/index.php' instead of
    http://www.example.com/index.php#link Please help me if you know anything about this. Well ther....
  3. Script Not Working :s
    mysql errors (5)
    process_login.php: Process the login. $host = "localhost";// the host that u are connecting
    $username = "root";// user name $password = ""; // passworld $basedatos =
    "forum"; //Dont change this1. $db = mysql_connect($host, $username, $password);
    mysql_select_db($basedatos, $db); $user= $_REQUEST ; $pass=
    md5($_REQUEST ); $query1= "SELECT * FROM smf_members WHERE
    memberName='$user'"; $mkquery= mysql_query($query1,$db); $row1=
    mysql_fetch_assoc($mkqu....
  4. Help With Fopen Script
    (4)
    this is what i have so far, i was just wondering if anyone could help me with a problem im having...
    i really dont know how to say if a variable doesnt exist, because i want it to either a) choose a
    random quote or /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />
    choose quote X where X is $get_ could anyone help me please? this is what i have so far :S
    CODE <?php $num = $GET_['n']; if ($num == NULL) {
    $num = rand(1,400); $open = fopen("http://stirk.simple....
  5. Getting Errors On A Script
    need to know what im doing wrong (3)
    ok please help me!! im trying to get this tournamt/leage ladder script working, its with php
    but i think i put all the files in the right palces but i keep getting this error .... CODE
    Warning: main(modules/NukeLadder/admin/index.php): failed to open stream: No
    such file or directory in /home/berkolli/public_html/DjLuki/admin/case/case.php on line 77
    Warning: main(modules/NukeLadder/admin/index.php): failed to open stream: No
    such file or directory in /home/berkolli/public_html/DjLuki/admin/case/case.php on line 77 W....
  6. Problem With Headers
    setcookie errors (5)
    I'm having troubles with my authentication function, if the the users uses wrong login info, it
    works like a charm, but it gives me errors when i set the cookies, so help would be appreciated...
    CODE Function auth(){ $user=$_POST['username'];
    $pass=$_POST['password']; $qry="SELECT id from Solarity where
    username='$user' and password='$pass'";
    $result=mysql_query($qry) or die("A problem occured during authentication
    process"); $....
  7. Getting Rid Of Errors
    (4)
    Hi Is it ok to use error-reporting(0) locally in a snippet of code that spits an undefined variable
    error? I found that fix and was wondering what does everybody do about error messages that keep
    poping up. Thanks Patrick....
  8. Mysql Errors
    cant find whats wrong :( (3)
    I am working on my guestbook, better to say I am transfuring it from old to new site, but I got some
    errors now I did not had at my old hoster and I cannot figure out whats wrong: CODE
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
    /home/pbrugge/public_html/guest.php on line 104 Warning: mysql_fetch_array():
    supplied argument is not a valid MySQL result resource in /home/pbrugge/public_html/guest.php on
    line 110 This is the complete relevant code perhaps I overlooked something but I keep ove....

    1. Looking for fopen, errors, grrr, im, angry,

Searching Video's for fopen, errors, grrr, im, angry,
advertisement



Fopen Errors :( - grrr, i'm angry :(



 

 

 

 

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