Jump to content

[SOLVED] MySQL syntax error


Etherwood

Recommended Posts

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 '= testdb' at line 1

 

$query=mysql_query("select * from users where database = '$database'") or die(mysql_error());

 

PHP 5.2.9

MYSQL 5.0.77

Link to comment
https://forums.phpfreaks.com/topic/181688-solved-mysql-syntax-error/
Share on other sites

As you can imagine, the word database probably has significance to a database - http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

 

If you truly have a column named database, you must enclose it in back-ticks ` so that it will be treated as an identifier instead of a reserved keyword.

 

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.