|
-
Jul 17th, 2015, 07:02 AM
#10
Re: [RESOLVED] Getting Mysql syntax error where there wasn't one before...
Yes order is a key word: ORDER BY ... so you need to tell MySql that your order is the field object order. And in MySql that's done by using the back ticks....
UPDATE part_storage.photos SET `order`='0' WHERE imgURL='2015_07_08-10_39_07am3.jpg'
see the ` around order, as opposed to ' around the data?
Upper helft hand on the keyboard, next to the 1 key...
That said... why is order a string? Should be a number. Here's why: as long as you have 9 or less to order you'll be fine because it will go 1,2,3,4,5,6,7,8,9 ... but once you cross over in to 10... you'll get 1,10,2,3,4,5,6,7,8,9 and then 1,10,11,2,3,4,5,6,7,8,9 strings don't sort numbers ... it's a string and will be treated as such. It just happens to look like a number. But if you change it to a numerical datatype... then you can order by `order` and it will sort properly.
Suggestion - change the field name to Sequence and the datatype to integer, drop the ' marks around the data for Sequence and if you're truly feeling saucey, use parameters, although the odds of a sql injection or mal-formed sql in this case is quite minimal.
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|