I have the following INSERT snippet that works fine:
$sql = "INSERT INTO `rating`(`business_id`, `user_id`, `quality`, `service`, `value`) VALUES (?,?,?,?,?)";
$query = $dbh->prepare($sql);
$query->bindParam(1, $business_id, PDO::PARAM_STR, 255);
$query->bindParam(2, $user_id, PDO::PARAM_STR, 255);
$query->bindParam(3, $quality, PDO::PARAM_STR, 255);
$query->bindParam(4, $service, PDO::PARAM_STR, 255);
$query->bindParam(5, $value, PDO::PARAM_STR, 255);
$query->execute();
However I would like to update another table if the insert was successful.
I thought this would do it:
if ($stmt->execute()) {
$sql = "UPDATE users SET prestige = prestige + 5";
$query = $dbh->prepare($sql);
$query->execute();
}
But no luck, can anyone point me in the right direction?
Final Code that works:
if ($query->execute()) {
$sql = "UPDATE user SET prestige = prestige + 250
WHERE id = {$user_id}";
$query = $dbh->query($sql);
}