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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php