Jump to content

SQL syntax error??


EmperorDoom

Recommended Posts

Hey I don't know what to make of this.. one minute it was working and then it wasn't.. I got this error msg:

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 ''default' WHERE date LIKE '2006-09%'' at line 1

here's a snippet of the code

$query="SELECT * FROM '$table' WHERE date LIKE '$date%'";
$result=mysql_query($query) or DIE(mysql_error());

$table is set to 'default' and $date is set to '2006-09'
I couldn't find any answers when i searched so I appreciate any help
thanks
Link to comment
https://forums.phpfreaks.com/topic/20265-sql-syntax-error/
Share on other sites

Remove the single quotes('') surrounding $table ('$table') and use ``(backticks) instead. Having used a MYSQL [url=http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]reserved word[/url] as a table name you'll have to surround the name with backticks in possibly all references to the table.
Link to comment
https://forums.phpfreaks.com/topic/20265-sql-syntax-error/#findComment-89189
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.