[php]if(isset($_POST[‘save’])){
$menu_name = ‘New Product’;
$position = 2;
$visible = 1;
$id = 2;
$conn->query("UPDATE subjects menu_name=:menu_name, position=:position, visible=:visible WHERE id=:id");
$stmt->execute(array(
'menu_name' => $menu_name,
'position' => $position,
'visible' => $visible,
'id' => $id
));
}[/php]
Where is the error of this code ? If I run this code to update subjects table I am gatting error like bellow.
Fatal error: Uncaught exception ‘PDOException’ with message ‘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 ‘=:New Product, position=:position, visible=:visible WHERE id=:id’ at line 1’ in C:\xampp\htdocs\php\widget_corp\edit_subject.php:124 Stack trace: #0 C:\xampp\htdocs\php\widget_corp\edit_subject.php(124): PDO->query(‘UPDATE subjects…’) #1 {main} thrown in C:\xampp\htdocs\php\widget_corp\edit_subject.php on line 124
Please help me to do this.