mysqli准备声明无效

时间:2022-08-21 13:22:31

I have been stuck on this mysqli statment for a while. I can't see what wrong with it and i can get the error to display so i can see where i am going wrong.

我一直坚持这个mysqli的声明。我看不出它有什么问题,我可以得到错误显示,所以我可以看到我错在哪里。

Can you please help me with this error or please explain to me how to display the error so I can fix it.

你可以帮我解决这个错误,或者请向我解释如何显示错误,以便我可以解决它。

this is my code

这是我的代码

$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 个解决方案

#1


0  

to view the error, change

查看错误,更改

if( $add_record->execute() ){
                $pass_list = '<li>Good to go</li>'; 
            } else {
                $error_list .= '<li>SQL error</li>';
                echo $db->error;    
            }

to

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

        }

also don't forget to close the statment when you're done

当你完成时也不要忘记关闭声明

$add_record->close();

also, depending on where you echo your error, it might not display on an html page. to check for this, view your page source

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

#2


0  

Oh My God, I hate these small error. I wasted more that 5 hours on this error which was so simple. the file path in my action path in the form was pointed to the incorrect file and that's why I kept on getting this error.

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

Thanks guys for your time.

谢谢你们的时间。

#1


0  

to view the error, change

查看错误,更改

if( $add_record->execute() ){
                $pass_list = '<li>Good to go</li>'; 
            } else {
                $error_list .= '<li>SQL error</li>';
                echo $db->error;    
            }

to

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

        }

also don't forget to close the statment when you're done

当你完成时也不要忘记关闭声明

$add_record->close();

also, depending on where you echo your error, it might not display on an html page. to check for this, view your page source

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

#2


0  

Oh My God, I hate these small error. I wasted more that 5 hours on this error which was so simple. the file path in my action path in the form was pointed to the incorrect file and that's why I kept on getting this error.

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

Thanks guys for your time.

谢谢你们的时间。