note 58007 added to function.fopen

From: Date: Fri, 21 Oct 2005 11:27:59 +0000
Subject: note 58007 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-97347@lists.php.net to get a copy of this message
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> ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58007 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58007&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58007&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97347) next »