user1380936
user1380936

Reputation:

SQL syntax error in query

What is wrong with my MySQL Query that is displaying the 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 'index WHERE id=1' at line 1

Relevant code:

$qu = mysql_query("SELECT * FROM index WHERE id= 1") or die("MySQL ERROR: ".mysql_error());

    WHILE($d = mysql_fetch_array($qu)):

    $con = $d['content'];

endwhile;

Upvotes: 1

Views: 71

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171391

index is a MySQL reserved keyword, so you must quote it with backticks like this:

SELECT * 
FROM `index` 
WHERE id = 1

Upvotes: 7

Related Questions