PDO无效参数

时间:2015-01-27 21:09:17

标签: php pdo

在开始之前,我知道还有其他类似的问题,但我无法从中获得任何解决方案。我的代码工作正常,直到我意外删除它,然后不得不重新制作它。

$sql    = "INSERT INTO inquiries (name, email, phone, date, message, event-type, guests, event-budget) VALUES (:name, :email, :phone, :date, :message, :event-type, :guests, :event-budget)";
$stmt   = $pdo->prepare($sql);
$result = $stmt->execute(array( ':name' => $_POST['name'],
                                ':email' => $_POST['email'],
                                ':phone' => $_POST['phone'],
                                ':date' => $_POST['date'],
                                ':message' => $_POST['message'],
                                ':event-type' => $_POST['event-type'],
                                ':guests' => $_POST['guests'],
                                ':event-budget' => $_POST['event-budget']
                               ));
if($result) {
    $tpl->define("alert", "<div class='col-md-12'><div class='alert-success' style='margin-left: 0; margin-bottom: 20px;'><h3><img src='http://criesvals-mbp.home:5757/_zip/_templates/_front/Refresh/multi-page/assets/images/head_img1.png' alt='' class='pull-left small_design_left'>Your Appointment Has Been Submitted<img src='http://criesvals-mbp.home:5757/_zip/_templates/_front/Refresh/multi-page/assets/images/head_img1.png' alt='' class='pull-right small_design_right'></h3></div></div>");
    $tpl->define('hide', 'style="display: none;"');
} else {
    $tpl->define("alert", "<div class='col-md-12'><div class='alert-failure' style='margin-left: 0; margin-bottom: 20px;'><h3><img src='http://criesvals-mbp.home:5757/_zip/_templates/_front/Refresh/multi-page/assets/images/head_img1.png' alt='' class='pull-left small_design_left'>There was an error submitting your appointment. Please try again later.</h3><img src='http://criesvals-mbp.home:5757/_zip/_templates/_front/Refresh/multi-page/assets/images/head_img1.png' alt='' class='pull-right small_design_right'></div>");
    $tpl->define('hide', 'style="display: none;"');
}

1 个答案:

答案 0 :(得分:2)

尝试使用短划线:event-type更改参数名称为无短划线:eventType等...

可能message, "event-type", guests, ...

非常欢迎你! : - )