- Impact
- 18
PHP:
// get timestamp
$time = time();
// qs
$thisqshere = addslashes(htmlspecialchars($_SERVER['QUERY_STRING']));
// ip
$ip = $_SERVER['REMOTE_ADDR'];
// check vars...
if($q == $_SESSION['q']){
// we are searching for what we searched for before...
if(!isset($_SESSION['search_id']) || empty($_SESSION['search_id'])){
// this means that there is either no search id or it is empty...
// so get the info from the db...
// find the last known q... and get that search id - this shouldn't happen though
$sql = "SELECT * FROM all_searches WHERE query='".addslashes($_SESSION['q'])."' ORDER BY 'id' DESC";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$_SESSION['search_id'] = $row['id'];
}
// now there is deffo a $_SESSION['search_id']
$sql = "UPDATE all_searches SET pages=pages+1 WHERE id='".$_SESSION['search_id']."'";
mysql_query($sql) or die(mysql_error());
}
else{
// searching for something different...
// do db thing:
$sql = "INSERT INTO all_searches (id,m,query,ip,time,querystring,pages) VALUES (NULL, '$m', '".addslashes($q)."', '$ip', '$time', '$thisqshere','1')";
$res = mysql_query($sql);
if($res){
$_SESSION['q'] = $q;
}
$_SESSION['search_id'] = mysql_insert_id();
}
mysql_close($dbc);
It just dosen't seem to add anything to the db...
here is the page with the session vars on it:
PHP:
// lets get the "query"
if(!isset($_GET['q'])){
header("Location: index.php?m=$m");
}
else{
$q = htmlspecialchars(stripslashes($_GET['q']));
}
$q = urldecode($q);
// make sure no spiders:
if(eregi("google",$HTTP_USER_AGENT)){
$spider = true;
}
else{
$spider = false;
}
// do the search sessions...
if(!isset($_SESSION['q'])){
// no session q
$_SESSION['q'] = $q;
// now there is...
}
// now we need to do the db thing:
if(!$spider){
include "includes/db_stats.php";
}
that last bit (includes/db_stats.php) is the file above...
I can't see why it dosen't work?!
Thanks
Tom
Last edited by a moderator:








