I am trying to incorporate a simple hit counter into my web page with the following code.....but it does not display the value of counter. It just displays "You are visitor " and not value for counter. The counter field in the table is getting updated successfully. There are only 2 fields in the table page and counter.
<?php
$db=mysql_connect("localhost", "username", "password");
mysql_select_db(homenetguy,$db);
mysql_query("UPDATE hits SET counter=(counter + 1) WHERE page='$PHP_SELF'",$db);
if (mysql_affected_rows($db) < 1) {
$result = mysql_query("INSERT INTO hits VALUES('$PHP_SELF',1)",$db);
}
$result = mysql_query("SELECT counter FROM hits",$db);
while ($row = mysql_fetch_row($result)) {
print ("You are visitor ");
print $row["counter"];
}
?>