EmperorDoom Posted September 10, 2006 Share Posted September 10, 2006 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 1here'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 helpthanks Quote Link to comment Share on other sites More sharing options...
shoz Posted September 10, 2006 Share Posted September 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
EmperorDoom Posted September 10, 2006 Author Share Posted September 10, 2006 hey thanks a lot .. that worked.. I hate how simple some of this stuff really is ;P Quote Link to comment Share on other sites More sharing options...
.josh Posted September 10, 2006 Share Posted September 10, 2006 just to be clear, using backticks isn't necessary unless you are using a mysql reserved word as a table or field name, though it's good practice not to use reserved words as table/field names to begin with. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 10, 2006 Share Posted September 10, 2006 Agreed... just never use them, and that way, you'll find out what the reserved words are to begin with. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.