This is a discussion on mysterious syntax error within the alt.comp.lang.php forums, part of the PHP Programming Forums category; query failed:1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
query failed: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 'desc) values('9','24','testing')' at line 1 INSERT INTO logins(accountid,userid,desc) values('9','24','testing') I don't see the error. what's going on ? |
|
|||
|
meltedown wrote:
> query failed: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 'desc) values('9','24','testing')' at line 1 > > INSERT INTO logins(accountid,userid,desc) values('9','24','testing') > > I don't see the error. what's going on ? DESC is a MySQL keyword. Try escaping it with tick-marks, i.e. `desc` One other thing, integers shouldn't be escaped with quotes. So the whole query should be: INSERT INTO logins(accountid, userid, `desc`) values(9, 24, 'testing') However, if I were you I'd choose a different name for your desc field, because it's only going to get confusing or cause hidden errors later down the line. -- Oli |
|
|||
|
Oli Filth wrote:
> meltedown wrote: > >> query failed: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 'desc) values('9','24','testing')' at line 1 >> >> INSERT INTO logins(accountid,userid,desc) values('9','24','testing') >> >> I don't see the error. what's going on ? > > > DESC is a MySQL keyword. Try escaping it with tick-marks, i.e. `desc` > > One other thing, integers shouldn't be escaped with quotes. So the whole > query should be: > > INSERT INTO logins(accountid, userid, `desc`) values(9, 24, 'testing') > > However, if I were you I'd choose a different name for your desc field, > because it's only going to get confusing or cause hidden errors later > down the line. > Ha Ha ! I orinally had a field 'in' that didn't work so I tried 'desc'. I guess 'in' is a keyword too.k Thanks, it works. I'll just change the field names. |