Hi there. I have made this script that tells the user how many indevidual users have visited that individual page. The table 'hitlog' contains the page url, and the amount of hits the page has had. If the page does not exist in the DB, thje program will create it, and set the hitcount to '1'. However, it doesnt seem to work, and i cant see why!! Any suggestions would be greatly appreciated.
Jonathan
<?php
// Connect to Database
$db = mysql_connect("eeeee.com", "55555", "55555") 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";
?>