useragent select...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
poetfreak
Forum Newbie
Posts: 2
Joined: Wed Jul 21, 2010 12:49 pm

useragent select...

Post 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
....
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: useragent select...

Post by AbraCadaver »

You don't use quotes ' around table and column names. You can use backticks ` if you want.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
poetfreak
Forum Newbie
Posts: 2
Joined: Wed Jul 21, 2010 12:49 pm

Re: useragent select...

Post 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.
Post Reply