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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.