X96 Web Design
05-24-2009, 02:54 AM
Hey All,
I'm making a MySQL/PHP hit counter, to "sniff" the browser and calculate how many times each browser is hitting my site.
Here's what I have:
$bowser_sniff == $_SERVER['HTTP_USER_AGENT'];
$db = mysql_connect("localhost", "user", "passwd");
mysql_select_db("hits_db",$db);
mysql_query("UPDATE hits SET counter=counter+1 WHERE browser = '$bowser_sniff'",$db);
if (mysql_affected_rows($db) < 1) { $result = mysql_query("INSERT INTO hits VALUES ('$bowser_sniff', 1)", $db); }
I've got the hits updating, but the browser isn't being added, I just get a blank entry.
And help would be appreciated.
I'm almost certain it's something to do with the variable in the mysql_query
Thanks
X96
I'm making a MySQL/PHP hit counter, to "sniff" the browser and calculate how many times each browser is hitting my site.
Here's what I have:
$bowser_sniff == $_SERVER['HTTP_USER_AGENT'];
$db = mysql_connect("localhost", "user", "passwd");
mysql_select_db("hits_db",$db);
mysql_query("UPDATE hits SET counter=counter+1 WHERE browser = '$bowser_sniff'",$db);
if (mysql_affected_rows($db) < 1) { $result = mysql_query("INSERT INTO hits VALUES ('$bowser_sniff', 1)", $db); }
I've got the hits updating, but the browser isn't being added, I just get a blank entry.
And help would be appreciated.
I'm almost certain it's something to do with the variable in the mysql_query
Thanks
X96