I am trying to get started with PDO and I am having problems. Here is my original code:
$query = " UPDATE `products` SET `product_qty` = '{$_GET['product_qty']}' WHERE `product_id` = '{$_GET['product_id']}' "; mysql_query($query) or die(mysql_error());
This works fine, but when I try to translate this into PDO syntax:
$db->prepare(' UPDATE products SET product_qty = :product_qty WHERE product_id = :product_id '); try { $db->execute(array(':product_qty' => $_GET['product_qty'], ':product_id' => $_GET['product_id'])); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); }
I get an error message:
Fatal error: call to undefined PDO :: execute () method in ...
Can someone help me get my first PDO request?
source share