Page 1 of 1

mysql syntax error... has anyone experienced?

Posted: Thu May 06, 2010 8:58 am
by rnoack
In the last day mysql has been getting EXTREMELY picky.
I'm been using it for quite some time and it's never done this before so I don't really understand.

For example I will do:
SELECT field FROM table WHERE user='Me';

and I get an error like 'check your mysql syntax on line 1 near user)
?!?!

but if i do:
SELECT `field` from `table` where `user`='Me';
then it works fine.

it absolutely never was this picky before... and after looking at the docs i'm not even convinced the ` are correct mysql syntax???

this also caused an error in my php that was very weird.... i had a query like the above one, but it didn't give an error.... then when i was trying to compare the value from the database with a local variable .... nope. Why? I thought... so I added

Code: Select all

print_r ($row)
(after $row=mysql_fetch_asssoc(........) )

php printed out the entire row.... but instead of 'Me' for the value of user just ['user'] => ''

WHAT???????????
I couldn't believe it.
So I went to phpadmin and copied the EXACT query... returned the full row, WITH a value for user 'Me'.

What is going on........!!!!!!!!


Has anyone else had issues like this in the past?

Re: mysql syntax error... has anyone experienced?

Posted: Thu May 06, 2010 9:49 am
by mikosiko
maybe it will help:

http://book.opensourceproject.org.cn/la ... ect_5.html

and also you can google "mysql backstick usage" to learn the Pros/Cons about it usage

and in another thought ... is the select that you posted your real select or just an example?... asking because "table" is a Mysql reserved word and can be the culprit of your problem.