NYCPHP Meetup

NYPHP.org

[nycphp-talk] Problem with MySQL UPDATE syntax

tedd tedd at sperling.com
Sat Jan 12 10:45:53 EST 2008


At 9:39 AM -0600 1/11/08, Tony Furnivall wrote:
>Hi!
>
>I'm having a problem with the UPDATE syntax for MySQL
>
>(aside - I hate products that tell me I have a syntax problem, but 
>don't tell me what it is - and then suggest that I go RTFM  which is 
>equally uninformative:-()
>
>I'm replacing the entire set of fields, WHERE a condition exists for 
>some of the fields, ie
>
>UPDATE table_name SET field1 = ' value1', field2 = ' value2', field3 
>= ' value3, field4 = ' value4'  WHERE field1 = ' value1' AND field2 
>= ' value2';
>
>MySQL says that I have error 1064 'near WHERE field1 = ' value1' AND 
>field2 = ' value2'
>
>but it doesn't say what therror is (grrr!)

Why the extra space before value1 (i.e., field1 = ' value1') ?

And where are the variables?

Shouldn't you be using something like:

UPDATE table_name SET field1 = '$value1',

That works for me.

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list