mysqli准备声明不起作用

时间:2013-03-24 00:35:54

标签: php mysql 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;    
            }

2 个答案:

答案 0 :(得分:0)

查看错误,更改

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

        }

也不要忘记在完成后关闭声明

$add_record->close();

另外,根据您回复错误的位置,它可能不会显示在html页面上。要检查这一点,请查看您的页面来源

答案 1 :(得分:0)

哦,天哪,我讨厌这些小错误。我在这个错误上浪费了5个多小时,这很简单。表单中我的操作路径中的文件路径指向不正确的文件,这就是我继续收到此错误的原因。

谢谢你们的时间。

相关问题