я не могу понять, почему этот запрос не работаетPDO запрос не работает
if ($productName && $productDescription && $productPrice) {
// SQL
// UPDATE `prostud_tristurion`.`products` SET `product_title` = 'ajax test', `product_description` = 'Was certainty remaining engrossed applauded sir how discovery.', `product_price` = '524' WHERE `products`.`product_id` = 10;
try {
$query = "update products set product_title = :pName, product_description = :pDescription, product_price = :pPrice, where product_id = :pid";
//prepare query for excecution
$stmt = $con->prepare($query);
//bind the parameters
$stmt->bindParam(':pid', $id);
$stmt->bindParam(':pName', $productName);
$stmt->bindParam(':pDescription', $productDescription);
$stmt->bindParam(':pPrice', $productPrice);
// echo "$productPrice/$productDescription/$productName/$id\n $stmt";
var_dump($_POST);
// Execute the query
if ($stmt->execute()) {
echo "Record was updated.";
} else {
die('Unable to update record.');
}
}catch(PDOException $exception){ //to handle error
echo "Error: " . $exception->getMessage();
}
}
все я получаю Невозможно обновить запись.
var_dump($_POST);
выглядит хорошо
'product_price =: pPrice,' <= это запятая. * «Все, что я получаю, не может обновить запись». * Вы не проверяете наличие ошибок. *Капризный капризный*. 'setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION)' –