Unique Visitor Counter?
<p>I have found a script that will allow me to display the number of unique visitors, but there seems to be a problem. It counts me three times before it stops. I am not good in PHP, but i tried to figure out the problem, but could not. Is there something wrong in my code? Is there another better, easier way to do this?</p>

<pre><code>&lt;?php

$filename = "UniqueCount.txt";

if (!file_exists($filename))
{
// hits.txt doesn't exist, let's try to create it.
$fd = fopen($filename, "w+");
fclose($fd);
}

$file = file($filename);
$file = array_unique($file);
$hits = count($file);

// Print out the number of unique visitors we have had.
echo $hits;

$fd = fopen($filename, "r");
$fstring = fread($fd, filesize($filename));
fclose($fd);

$fd = fopen($filename, "w");
$fcounted = $fstring . "
" . $_SERVER["REMOTE_ADDR"];
$fout = fwrite($fd, $fcounted);
fclose($fd);

?&gt;
</code></pre>

<p>To boot, when it creates the file. I get and error, saying</p>

<p><code>0
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/content/46/10721146/html/UniqueHits.php on line 20</code></p>

<p>Thanks in advance, </p>

<p>Elite Gamer</p>
