Jump to content
xisto Community
tracdoor

Fopen Errors :( grrr, im angry :(

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.