Thanks laserlight,
Overlooking the IF condition, yes you could write it like that. Sure.
Thanks cahva,
If I understand you correctly, your soulution hinges on single qoutes
To wrap in the definition -- $return_visits='NULL';
AND
To OMIT in the values string of the insert query -- ('$browser','$ip',now(),'$page',$return_visits)";
???
I was under the impression that
$return_visits='NULL';
Would simply insert the string 'NULL' as distinct from the MYSQL VALUE NULL
AND THAT
-
AS A STRING, I would be required to WRAP the '$variable' in the $query
???
Hmmm... I'm off to experiment with that some more...
P.S. For a little beter context I have re-written the whole thing as follows... though I still belieive it can be refined and simplified.
if($same_visit !='true'){
$chk_return ="SELECT * FROM stattracker WHERE ip='$ip'AND date_visited < DATE_SUB(NOW(),INTERVAL 1 HOUR)";
$result=mysql_query($chk_return);
$num_rows = mysql_num_rows($result);
if($num_rows!='0'){
$values="VALUES('$browser','$ip',now(),'$page','$from_page','$hostname','yes')";
}
}
else{
$values="VALUES('$browser','$ip',now(),'$page','$from_page','$hostname', NULL)";
}
//Insert hit data in stattracker table...
$query_insert ="INSERT INTO stattracker
(browser,ip,date_visited,page,from_page,hostname,return_visits) $values";