Counter has gremlins

From: Date: Tue, 18 Feb 2003 00:45:59 +0000
Subject: Counter has gremlins
Groups: php.general 
Request: Send a blank email to php-general+get-135930@lists.php.net to get a copy of this message
I have this basic counter: <?php $counterFile = "./counter.txt"; function displayCounter($counterFile) { global $counted; $fp = fopen($counterFile, 'rw'); $num = fgets($fp,7); if (!$counted) { $num += 1; unlink("$counterFile"); exec("echo $num > $counterFile"); } print "Visitor #$num"; } if (!file_exists($counterFile)) { exec("echo 1 > $counterFile"); } displayCounter($counterFile); ?> Works like a charm but every so often for no apparent reason it resets to 0. Anyone see anything wrong here to cause that?

« previous php.general (#135930) next »