嗯,看来你的 SQL 语句不需要单引号。例如,您可以尝试运行此块:
$STH = $DBH->prepare("UPDATE b_temp_booking
SET check_in = :check_in,
check_out = :check_out,
adults = :adults,
children1 = :children1,
children2 = :children2,
infants = :infants,
cots = :cots,
promo_code = :promo_code
WHERE temp_booking_id = :temp_booking_id");
查看有关 PDO 准备语句的 PHP 手册:http://www.php.net/manual/en/pdo.prepared-statements.php看起来这里命名占位符周围不需要引号。
另外,请尝试遵循他们使用 bindParam() 方法的示例:
$STH->bindParam(':temp_booking_id', $temp_booking_id);
$temp_booking_id = $_SESSION['temp_id']; // Not sure how binding the environment variable will work, so decoupling it.
$STH->bindParam(':check_in', $in);
$STH->bindParam(':check_out', $out);
$STH->bindParam(':adults', $a);
$STH->bindParam(':children1', $c1);
$STH->bindParam(':children2', $c2);
$STH->bindParam(':infants', $i);
$STH->bindParam(':cots', $c);
$STH->bindParam(':promo_code', $pc);
当您准备好执行时,可以运行以下行:
$STH->execute();
检查一下,看看绑定参数是否是您想要的。