Page 1 of 1

useragent select...

Posted: Wed Jul 21, 2010 12:52 pm
by poetfreak
I am designing a simple php script to track how many hits I get on each browser to warm up with MySql... but I am failing at the select statement. If you could tell me what is wrong I would appreciate because this should work as far as everything I have read. I just modified the MySQL query from phpMyAdmin and added WHERE name='Firefox 3.3.6' Like so:

Code: Select all

@mysql_select_db("testbed") or die('DATABASE SELECT ERROR - ' . mysql_error());
// See if the current browser has a count entry ...
$Q = "SELECT * FROM 'browserhits' WHERE name = '" . $BROWSER . "';";
mysql_query($Q) or die(mysql_error() . '<br>' . $Q);

$count = mysql_num_rows();
if ($count > 0) {
// UPDATE count
....

Re: useragent select...

Posted: Wed Jul 21, 2010 12:55 pm
by AbraCadaver
You don't use quotes ' around table and column names. You can use backticks ` if you want.

Re: useragent select...

Posted: Wed Jul 21, 2010 2:36 pm
by poetfreak
so yeah, I discovered that variable names need backticks, and data needs double quotes, and not single quotes or backticks. Thank you for your help, my eyes are bad and I did not even see that.