mysql syntax error... has anyone experienced?

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
rnoack
Forum Commoner
Posts: 34
Joined: Mon May 03, 2010 12:38 am

mysql syntax error... has anyone experienced?

Post 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?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

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

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