Forum Moderators: coopster

Message Too Old, No Replies

You have an error in your SQL syntax

check the manual that corresponds to your MySQL server version for the righ

         

miltaij

10:43 am on Sep 2, 2008 (gmt 0)

10+ Year Member



I have been banging my head trying to find out where this syntax error is. I think it is somewhere in the following I left a comment.

/*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 'table' at line 1*/

$query = "SELECT * FROM table";

if(!($result = mysql_query($query, $database))){
print("Could not execute query!<br>");
die(mysql_error());
}

Anyango

11:49 am on Sep 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey miltaij,

Welcome to WebmasterWorld!

I would guess the word 'table' is reserved for mysql and we cannot use it as our database or table name, try changing your table name.

Reference:
[dev.mysql.com...]

[edited by: Anyango at 12:01 pm (utc) on Sep. 2, 2008]

omoutop

2:02 pm on Sep 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



table is reserved, but you can still use it :

select * from `table` (note the `)

but its better not to use reserved words. it will make your life much easier

PS: i have not test it with a table named "table", but this trick works with other reserved words (like text, date, etc)

piskie

3:10 pm on Sep 2, 2008 (gmt 0)

10+ Year Member



I find reserved words to be quirky and inconsistent with table one of the words that has caused me problems so I haven't used it for years now.