Hello. I have a php script that logs hits to my webpage into
a mysql table. The problem is that I cant get the script to exclude logging my own ip address, or others I define.
Either it logs all or none depending on if I set the
if($ip='88.202.66.8') or if($ip=='88.202.66.8').
If anybody could help me with this I would help me a lot ?
The script is below.
<?php
# Database and table connections file
include("connect.php");
# Variables
$ip=$_SERVER['REMOTE_ADDR'];
$browser=$_SERVER['HTTP_USER_AGENT'];
$date_now = date('Y.m.d - H:i:s');
$date_first = date('Y.m.d - H:i:s');
# Exclude my own ip
if($ip='88.202.66.8') {
#Nothing
}
# Include all other ip's
else {
$sql_insert = "INSERT INTO $table (browser,ip,date_now,date_first)
VALUES ('$browser','$ip','$date_now','$date_first')";
$do_insert = mysql_query($sql_insert);
}
# Counts number of hits
$sql_result = mysql_query("SELECT * FROM $table");
$loop = mysql_num_rows($sql_result);
$year_first = "2000";
$year_now = date('Y');
# Per year, month and day
$snitt_per_aar = $loop/($year_now-$year_first);
$snitt_per_mnd = ($snitt_per_aar/12);
$snitt_per_dag = ($snitt_per_aar/364);
# Prints to screen
echo "$loop hits | ";
echo ceil($snitt_per_mnd)." per/month";
?>