note 58007 rejected from function.fopen by betz

From: Date: Fri, 21 Oct 2005 12:32:54 +0000
Subject: note 58007 rejected from function.fopen by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-97350@lists.php.net to get a copy of this message
Note Submitter: dan_meren at yahoo dot com ---- Hey please help me, i am new to PHP. I am trying to run a php file counter.php which i have uploaded to my server but it is not working. Also, other php files (created by others before) are working fine on the same server. I am confused. Please help me out. I have also created the text file counter.txt and have entered 0 in it. This is the code I am trying to run. counter.php (code used from the forum) <html> <head> <title>Counter</title> </head> <body> <?php phpinfo(); //just to see if anything works or not! but even this is not working $file = "counter.txt"; $handle = fopen ($file, "r+"); // Let's open for read and write $count = int (fread ($handle, filesize ($file))); // We don't want to think it's a string and try appending echo "You are visitor number $count"; rewind ($handle); // Go back to the beginning /* * Note that we don't have problems with 9 being fewer characters than * 10 because we are always incrementing, so we will always write at * least as many characters as we read **/ fwrite ($handle, ++$count); // Don't forget to increment the counter fclose ($handle); // Done ?> </body> </html>

« previous php.notes (#97350) next »