Honesty Rocks! truth rules.

Fopen Errors :( grrr, im angry :(

HOME      >>       Programming


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);

<?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:
There have been <?php include ("/home/tracdoor/public_html/counter.php"); ?> hits.

It says:

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?


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


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 ^_^


I think it may have to do with the fact that open_basedir is enabled in Xisto. 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".


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


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.


It looks like there're problems with fopen.Try to call the support :D


$doesthiswork = "/home/tracdoor/public_html/hitcounter.txt";if (!is_writeable($doesthiswork)){echo 'The file is not writable';}test your file by using those code.Darren


file not open in phpFopen Errors :(

I m try to open file in php using fopen in write mode.

it give errorĀ 

as follow

Warning: fopen(/detail.Txt) [function.Fopen]: failed to open stream: No error in C:phptesttesttestfile.Php on line 7

I musing vsphp trial version as ide

-reply by alpeshKeywords: warning: fopen(/detail.txt) [function.fopen]: failed to open stream: no error in in php