hi guys
im trying to create a php mysql hit counter,it will counts hits on every page
here is the code
<?php
function log_hit(){
$page = mysql_real_escape_string(basename($_SERVER[ 'SCRIPT_NAME' ]));
//echo $page;
$sql = "INSERT INTO `hits` ( `page_name`, `hits` )
VALUE ( '{$page}', 1)
ON DUPLICATE KEY UPDATE `hits` = `hits` +1";
mysql_query($sql);
}
function fetch_stats(){
$result = mysql_query( 'SELECT `page_name`, `hits` FROM `hits` ' );
$stats = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$stats[ ] = $row;
}
return $stats;
}
?>
so by adding log_hit(); function in pages it will record hits
but im trying to restrict my ip address to be counted
i mean i dont want to that mysql record hits from certain IP address,in this case my ip address
so i added this codes
$ip = getenv("REMOTE_ADDR") ;
$myip = "127.0.0.1";
if ( $ip != $myip ){
//above code
}
it works good
but when i open a page gives me an errorr
Call to undefined function log_hit()
and nothing loads
how to ignore this error anf just force to loading page?