Forum Moderators: open

Message Too Old, No Replies

MYSQL gives error for To

         

akmac

6:30 pm on Mar 28, 2007 (gmt 0)

10+ Year Member



I get this error when I try to run a back up on my site:

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 'to,ended from contests' at line 1

select id,name,to,ended from contests

I think it has something to do with adding a module that has a db field called "to", but I'm not sure if that's it, or how to fix it...?

Thanks anyone for your time.

dreamcatcher

7:30 am on Mar 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi akmac,

TO is a mysql reserved word [dev.mysql.com] and cannot be used as a column name. Try renaming your column to something else.

dc

akmac

7:34 pm on Mar 29, 2007 (gmt 0)

10+ Year Member



Ah, I was hoping that wasn't it... '-)

eelixduppy

8:10 pm on Mar 29, 2007 (gmt 0)



Renaming it is the best approach to something like this, however, if you cannot rename it for whatever reason you have to escape it using the prime character(`). So your query would then look something like this:

select `id`,`name`,`to`,`ended` from contests

I just escaped each col just to show you :) I'd change the name of the col if you can, though.