mysterious syntax error

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


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-20-2005
meltedown
 
Posts: n/a
Default mysterious syntax error

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 ?
Reply With Quote
  #2 (permalink)  
Old 05-20-2005
Oli Filth
 
Posts: n/a
Default Re: mysterious syntax error

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
Reply With Quote
  #3 (permalink)  
Old 05-20-2005
meltedown
 
Posts: n/a
Default Re: mysterious syntax error

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0