Here is the script that is causing the problem:
$statime = date('Y-m-d G:i:s', time() -3600);
$statreferrer = "$_SERVER[REMOTE_ADDR]";
$urlParts = parse_url($_SERVER[HTTP_REFERER]);
parse_str($urlParts['query'], $queryParts);
$query_part = (empty($queryParts['q'])) ? '' : $queryParts['q'];
list($r1,$r2) = split('[/]', $urlParts['path']);
//echo "$query_part<br />";
//echo "$urlParts[path]<br />";
//echo "$r2";
if ($r2 == "browse") {
$stattype = 6;
}
elseif ($r2 == "categories") {
$stattype = 7;
}
elseif ($urlParts['path'] == "/search.php"){
$stattype = 5;
}else{
$stattype = 8;
}
if (isset($_COOKIE[stats])) {
$result_s1 = mysql_query("SELECT * FROM stats WHERE listingID = '$row_i1[listingID]' AND statType = '$stattype' AND statKeyword = '$query_part' and statReferrer = '$statreferrer'");
$num_rows_s1 = mysql_num_rows($result_s1);
if ($num_rows_s1 == 0) {
$sql= "INSERT INTO stats (listingID,statType,statKeyword,statReferrer,statDate) VALUES ('$row_i1[listingID]','$stattype','$query_part','$statreferrer','$statime')";
if (!mysql_query($sql,$connect)) {
die('Error: ' . mysql_error());
}
}
}else{
$sql= "INSERT INTO stats (listingID,statType,statKeyword,statReferrer,statDate) VALUES ('$row_i1[listingID]','$stattype','$query_part','$statreferrer','$statime')";
if (!mysql_query($sql,$connect)) {
die('Error: ' . mysql_error());
}
}