Mysql Query Invalid

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Mysql Query Invalid

Post 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
User avatar
micknc
Forum Contributor
Posts: 115
Joined: Thu Jan 24, 2008 11:13 pm

Re: Mysql Query Invalid

Post 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.
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: Mysql Query Invalid

Post by ashebrian »

correct
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Re: Mysql Query Invalid

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Mysql Query Invalid

Post 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.
Post Reply