Re:RE: [PHP] problem with counter

From: Date: Sat, 19 Aug 2000 21:46:35 +0000
Subject: Re:RE: [PHP] problem with counter
Groups: php.general 
Request: Send a blank email to php-general+get-12610@lists.php.net to get a copy of this message
hi I'm having the same problem with this code: <?php $counterFile ="/var/virtual/internet2001.com.br/files/www/htdocs/progado.com.br/acessos.txt"; if (file_exists($counterFile)){ $fil = fopen( $counterFile, 'r'); $dat = fread($fil, filesize( $counterFile)); $counted = $dat+1; fwrite($fil, $counted); fclose($fil);} else{ $fil = fopen($counterFile, w); fwrite($fil, 1); $counted = 1; fclose($fil);} echo "You are visitor #", $counted; ?> hi there someone can explain why this counter is counting only until 2? thanks <?php $counterFile ="/var/virtual/internet2001.com.br/files/www/htdocs/progado.com.br/acessos.txt"; function displayCounter($counterFile) { $fp = fopen($counterFile,r); $num = fgets($fp,5); $num += 1; fclose($fp); print "$num"; exec( "rm -rf $counterFile"); exec( "echo $num > $counterFile"); } if (!file_exists($counterFile)) { exec( "echo 1 > $counterFile"); } displayCounter($counterFile); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#12610) next »