Lovelock
Lovelock

Reputation: 8085

SQLSTATE[42000] Error

Cant figure out where this query is going wrong...

getting this error:

{"databaseException":"SQLSTATE[42000]: Syntax error or access violation: 1064 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 'desc) \n    VALUES (1, array)' at line 1"

from this query

$statement = $db->prepare(
"INSERT INTO `descriptions` (vrm, desc) VALUES (:vrm, :description)"
);

if ($statement->execute(array(
':vrm' => '1', 
':description' => $_POST['desc'])));

Thanks!

Upvotes: 0

Views: 121

Answers (1)

Ruud
Ruud

Reputation: 36

You should add backticks to the desc column name. It's a reserved word (ORDER BY vrm DESC).

Upvotes: 2

Related Questions