View Full Version : Odd database query error

07-16-2005, 12:57 PM
What is wrong with this query:

$query = "SELECT order FROM side_articles WHERE ID LIKE '%" . $i . "%'";

I get the following MySQL error message with this query:

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 'order FROM side_articles WHERE ID LIKE '%1%'' at line 1

Huh? I can;t figure this out...The SQL table and columns exist, and so does the PHP variable $i....

help please...

07-16-2005, 05:29 PM
Nevermind, don't use 'order' as a column name....MySQL thinks you are using ORDER BY, and gets confused.... :rolleyes:

07-16-2005, 08:45 PM
I think you can use restricted names like that so long as you surround them by ` (backtick) characters:

$query = "SELECT `order` FROM `side_articles` WHERE ID LIKE '%" . $i . "%'";
That way MySQL knows that you are passing it field names not commands :)