Page 1 of 1

[SOLVED] You have an error in your SQL syntax

Posted: Sat Jul 31, 2004 10:51 am
by robster
Hi there, I've read the sticky forum post and tried the suggestions before asking this question, but I get this error:

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 'lines ORDER BY id DESC' at line 1

at this line of code:

Code: Select all

$result = mysql_db_query($dbname, "SELECT * FROM lines ORDER BY id DESC") or die(mysql_error());
I'm a bit lost now, I just can't see what I've done wrong. $dbname variable is the correct database and lines is the correct table.

Too strange, I'd really appreciate any suggestions.

Thanks :)

Rob

Posted: Sat Jul 31, 2004 11:05 am
by markl999
'lines' is a mysql reserved word. So either rename the column or backquote it, eg `lines`

Posted: Sat Jul 31, 2004 11:13 am
by robster
thank you so much!

:)

I changed it to another name and it worked a treat. Wow, no wonder I couldn't see the syntax error :)

Thanks again.

Rob

Posted: Sat Jul 31, 2004 12:13 pm
by robster
I don't suppose 'to' 'from' or 'draw' are also reserved words?

Posted: Sat Jul 31, 2004 12:19 pm
by markl999

Posted: Sat Jul 31, 2004 12:20 pm
by robster
thank you again, and thanks for that link. Very helpful :)