PDA

View Full Version : update query.. help


potpot
07-16-06, 10:43 PM
i have this query on my php script:

UPDATE uw_content SET content_order='2' WHERE content_id='1'
UPDATE uw_content SET content_order='1' WHERE content_id='2'

but i have problem, when i try to manually paste this to sql editor i got this error:

Error Code : 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE uw_content SET `content_order`='1' WHERE `content_id`='2
(0 ms taken)

and when i execute this script the table result is this :
the content order would be

3
1
1
4

the original one is:
1
2
3
4

and am trying to swap the 1 to 2, but when the script executes i got the result of:

3
1
1
4

any ideas guys?? thank you..

mab
07-16-06, 11:08 PM
If you send the query string directly to mysql through an editor/GUI, you need to put a semi-colon on the end of each line.

Also, if your table columns are integers, there should not be any quotes surrounding the numbers (both through PHP and directly through an editor.)

As to the results not being what you want, what are the starting and ending values for both - content_order and content_id? The only way you would replace two content_order values with one's is if those two had content_id = 2.

potpot
07-17-06, 01:51 AM
i get rid of the quote but i still get an problem, and also the starting value of content_order is 1, 2, 3, and 4 and the content_id are 1,2,3 and 4...