Re: Snarl, hiss, growl (frustration)

From: Date: Fri, 04 Jul 2003 14:42:59 +0000
Subject: Re: Snarl, hiss, growl (frustration)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153997@lists.php.net to get a copy of this message
Hi, Saturday, July 5, 2003, 12:33:25 AM, you wrote: KB> Why does this not work? It is just a simple hit counter (hence the KB> snarls, hissing, and growling). It logs the ips address but does not KB> increment $current or log it. I do have counter.txt and ips.txt chmod'd KB> to 777. Ips.txt starts blank and counter.txt starts with just a 0 in it. KB> <?php $counter = fopen('counter.txt', 'r'); KB> $current = fread($counter, filesize('counter.txt')); KB> fclose($counter); KB> $ip = getenv('REMOTE_ADDR'); KB> $ipCheck = file('ips.txt'); KB> if (!in_array($ip, $ipCheck)) { KB> $ipAdd = fopen('ips.txt', 'a'); KB> fwrite($ipAdd, "\n$ip"); KB> fclose($ipAdd); KB> $current++; KB> $counter = fopen('counter.txt', 'w'); KB> fwrite($counter, $current); KB> fclose($counter); KB> } print $current; ?>> KB> -- KB> Kyle maybe you need to end the if() statement before incrementing the counter. $ip = getenv('REMOTE_ADDR'); $ipCheck = file('ips.txt'); if (!in_array($ip, $ipCheck)) { $ipAdd = fopen('ips.txt', 'a'); fwrite($ipAdd, "\n$ip"); fclose($ipAdd); } $current++; $counter = fopen('counter.txt', 'w'); fwrite($counter, $current); fclose($counter); print $current; ?> -- regards, Tom

« previous php.general (#153997) next »