Page 1 of 1

Mysql Query Invalid

Posted: Mon Mar 24, 2008 5:39 pm
by Pezmc
What is wrong with this query? I have tried so many times to get it to work but I just can't see what is wrong with it.

Code: Select all

INSERT INTO gallery (`name`, `show`, `original`, `original_width`, `original_height`, `lightbox`, `lightbox_width`, `lightbox_height`, `thumb`, `thumb_width`, `thumb_height`, `description`) VALUES ('Pez Cuckow', 'yes, '/gallery/original/Pez_Cuckow.png', '1560', '599', '/gallery/lightbox/Pez_Cuckow.png', '800', '307', '/gallery/thumb/Pez_Cuckow.png', '200', '76', 'Fescrioti fjfj is dlskjfsa', '')
 
 
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 '', '1560', '599', '/gallery/lightbox/Pez_Cuckow.png', '800', '307', '/gallery/th' at line 2

Re: Mysql Query Invalid

Posted: Mon Mar 24, 2008 5:57 pm
by micknc
I see a couple of things
The second value needs to be changed from 'yes, to 'yes',
and the final value doesn't need a coma.

There could be more but that jumped out at me.

Re: Mysql Query Invalid

Posted: Mon Mar 24, 2008 6:03 pm
by ashebrian
correct

Re: Mysql Query Invalid

Posted: Tue Mar 25, 2008 3:08 am
by Pezmc
Thank you so much. Can anyone explain why mysql gave a completely useless error that wasn't even in the right place? I was using its error to try and fix the bug and litterally spent 30-40 mins trying to find this one! (then again it was 3am at the time). Once again thanks for the help :D

Re: Mysql Query Invalid

Posted: Tue Mar 25, 2008 4:46 am
by onion2k
MySQL's error tracking isn't that great, but to be fair to it tracking down a problem automatically is pretty damn hard.

Something else that's (possibly) wrong with your SQL is that you're quoting your INTs. '1560' should be 1560, otherwise MySQL has to convert it internally which it'll certainly get right but it's an added unnecessary step.