Hi there, i have a problem. This script sounts how many people have visited an indevidual page. However, when i load the page, all it prints is "Other People have Viewed This Individual Page" without the number in front. Ive checked my database and no data has been inputted. Any ideas what is wrong with it?
Cheers.
<?php
// Connect to Database
$db = mysql_connect("localhost", "user", "pass") or die ("Could not connect");
mysql_select_db("radar") or die ("Could not select db");
// What is the current page?
$page = $SERVER['HTTP_HOST'].$SERVER['PHP_SELF'];
// Check if the current page exists in DB
$sql = mysql_query("SELECT * FROM hitlog WHERE page='$page'",$db);
if(mysql_num_rows($sql) == 0) {
// If false, insert page into DB
$sql = "INSERT INTO hitlog(id, page, page_hits) VALUES ('', '$page', '1')";
mysql_query($sql);
} else {
// If true, update the number of hits for that page
$sql = "UPDATE hitlog SET page_hits='page_hits+1' WHERE page='$page'";
mysql_query($sql);
}
// Display Number of hits for that page
$hits = mysql_fetch_array(mysql_query("SELECT page_hits FROM hitlog WHERE page='$page' LIMIT 1",$db));
echo "<b>$hits</b> Other People have Viewed This Individual Page";
?>