Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble updating MySQL databse

Status
Not open for further replies.

Naits

Programmer
Oct 10, 2001
90
0
0
NO
I have this:
#
# Table structure for table 'browser'
#

CREATE TABLE browser (
id int(11) DEFAULT '0' NOT NULL,
type varchar(150) NOT NULL,
count int(11) DEFAULT '0' NOT NULL
);

Im trying to update it with this query:

$sql = "UPDATE browser SET count = count + 1 WHERE type = $browser";

FAIL's! But thi query works:

$sql = "UPDATE browser SET count = count + 1 WHERE id = 0";

Why can't I use the first one? I realy need it to work...
 
$sql = "UPDATE browser SET count = count + 1 WHERE type = '$browser'"; - note the addded single quotes
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Or, using a slightly different coding style:
Code:
$sql = "UPDATE browser SET count = count + 1 WHERE type = '".$browser."';";

I personally like to use the '.' when putting variable values in a string, but... it's just my personal preference.:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top