mysqli准备声明不起作用
问题描述:
我一直在这个mysqli陈述卡住了一段时间。我看不出它有什么问题,我可以得到显示的错误,以便我可以看到我出错的地方。mysqli准备声明不起作用
你能帮我解决这个错误吗?或者请向我解释如何显示错误,以便我可以修复它。
这是我的代码
$add_record = $db->prepare('UPDATE vehicles SET name= ?, VINnum= ?, maker= ?, model= ?, color= ?, year= ?, oilChange= ?, registrationExp= ?, insuranceExp= ?, dailyRate= ?, weekleyRate= ?, monthleyRate= ?, currentMillage= ?, oilChangeMillage= ?, licensePlate= ?, vehicleCost= ? WHERE Vehicles_id = ?');
$add_record->bind_param('sssssisssdddsssdi', $name, $VIN, $maker, $model, $color, $year, $oilChange, $registration, $insurance, $dailyRate, $weekleyRate, $monthleyRate, $currentMillage, $changeOilMillage, $plate, $cost, $id);
if($add_record->execute()){
$pass_list = '<li>Good to go</li>';
} else {
$error_list .= '<li>SQL error</li>';
echo $db->error;
}
答
查看错误,改变
if($add_record->execute()){
$pass_list = '<li>Good to go</li>';
} else {
$error_list .= '<li>SQL error</li>';
echo $db->error;
}
到
if($add_record->execute()){
$pass_list = '<li>Good to go</li>';
} else {
$error_list .= '<li>SQL error</li>';
echo $add_record->error."<br/>"; // <--- this is what you need to change
echo $db->error."<br/>"; // <--- this is what you need to change
}
也不要忘了,当你完成关闭statment
$add_record->close();
也取决于你回应你的错误的地方,它可能不会显示在HTML页面上。检查这个,查看你的页面源代码
答
哦,我的天啊,我讨厌这些小错误。这个错误非常简单,我浪费了5个小时。在我的行动路径在窗体中的文件路径被指向不正确的文件,这就是为什么我一直在得到这个错误。
感谢你们的时间。
一旦你使用下面的变化得到错误,你能否让我们知道一个编辑? – 2013-03-24 00:50:06