E
egobuilders
Guest
I built a custom visitor tracking database which gathers the number of hits and the frequency each IP address visited the site. However, I can't seem to get a count for unique visits... for example, I just want to know the first time each IP address visited the site. So, why won't this code work?
$myresult = mysql_query("SELECT visitor FROM stats WHERE frequency=1");
while($myvar = mysql_fetch_array($myresult)){
$mycount = $myvar['visitor'];
}
echo 'Unique visitors: ' . $mycount;
I tried this...
$mycount = mysql_query("SELECT count(distinct visitor) FROM stats");
echo 'Unique Visitors:' . $mycount;
...but it returned "Resource id #3" - How do I get the actual count?
I got it! Thanks for everyone's help!
$unique = mysql_fetch_array(mysql_query("SELECT count(distinct va_ip) FROM stats"));
echo $unique[0];
$myresult = mysql_query("SELECT visitor FROM stats WHERE frequency=1");
while($myvar = mysql_fetch_array($myresult)){
$mycount = $myvar['visitor'];
}
echo 'Unique visitors: ' . $mycount;
I tried this...
$mycount = mysql_query("SELECT count(distinct visitor) FROM stats");
echo 'Unique Visitors:' . $mycount;
...but it returned "Resource id #3" - How do I get the actual count?
I got it! Thanks for everyone's help!

$unique = mysql_fetch_array(mysql_query("SELECT count(distinct va_ip) FROM stats"));
echo $unique[0];