1

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;

1 Answer 1

7

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

SELECT * 
FROM `index` 
WHERE id = 1
Sign up to request clarification or add additional context in comments.

1 Comment

In other words, if you can come up with a better name for that table, you might want to rename it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.