Log in

View Full Version : Resolved Hit Counter Help



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

thetestingsite
05-24-2009, 01:46 PM
This line:



$bowser_sniff == $_SERVER['HTTP_USER_AGENT'];


remove one of the = and it should be good.

Hope this helps.

X96 Web Design
05-24-2009, 04:01 PM
Thanks! It works perfectly.

/ X96 \

Schmoopy
05-24-2009, 07:08 PM
Just a quick thing of no real importance but you have "bowser_sniff" instead of "browser_sniff" :p

X96 Web Design
05-24-2009, 07:55 PM
:D I know... I did that on purpose...

// X \\

Schmoopy
05-24-2009, 08:05 PM
Haha xD