PDO 无效参数
PDO Invalid Parameter
在开始之前,我知道还有其他类似的问题,但我无法从中得出任何解决方案。我的代码工作正常,直到我不小心删除了它,然后不得不重新制作它。
$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;"');
}
尝试将带破折号的参数名称 :event-type
更改为无破折号的名称 :eventType
等...
可能 message, "event-type", guests, ...
等
不客气! :-)
在开始之前,我知道还有其他类似的问题,但我无法从中得出任何解决方案。我的代码工作正常,直到我不小心删除了它,然后不得不重新制作它。
$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;"');
}
尝试将带破折号的参数名称 :event-type
更改为无破折号的名称 :eventType
等...
可能 message, "event-type", guests, ...
等
不客气! :-)