Forum Moderators: coopster
Whenever I access the php counter of my site I get some nasty errors, as below:
Warning: fopen(/home/romaniap/domains/.../public_html/phpmycounter/counter.dat) [function.fopen]: failed to open stream: Permission denied in /.../public_html/phpmycounter/counter.php on line 24
Warning: fputs(): supplied argument is not a valid stream resource in /.../public_html/phpmycounter/counter.php on line 25
Warning: fclose(): supplied argument is not a valid stream resource in /.../public_html/phpmycounter/counter.php on line 26
Now, this happens even after I set permission to 755 for all the files in the counter's folder and also for the folder.
(the 24, 25, 26th lines in "counter.php", to which errors reffer, are like this:
$fp = fopen($CONFIG['counter_data'], "w");
fputs ($fp, $count);
fclose ($fp);
)
It's strange, because the counter worked well before..
I just can't track the bug.... somebody any ideas..?
Thanx
You could chmod 777 (very BAD)
or you could change the owner of the folder to 99:99 (requires root priveledges)
Getting root privs may not be possible so what I do in this case is:
1) Create a PHP script that will simply create the directory.
<?php
mkdir("counter", 0755);
?>
Now PHP will be able to write to that folder with only 755 permissions.
Give it a go! It works.
[edited by: Birdman at 1:59 pm (utc) on May 12, 2007]