致命错误:在非对象PDO工作上调用成员函数execute()

时间:2014-12-02 00:02:23

标签: php mysql pdo

错误讯息:

致命错误:在第30行的非对象上调用成员函数execute()

第29和30行

$stmt = $pdo->prepare("INSERT INTO installs (customer_id, engineer_id, datetime, tracker, tracker_serial, tracker_sim, satnav, eco_plus, eco_plus_address, ttConnect, ttConnect_address, fms, remote_link, remote_link_address, remote_logbook, remote_logbook_address, registration, vehicle_make, vehicle_model, colour, mileage, box_location, comments, ip_address) VALUES (:1,:2,:3,:4,:5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24)");
$stmt->execute(array("1" => $customer_id, "2" => $engineer_id, "3" => $date, "4" => $tracker, "5" => $tracker_serial, "6" => $tracker_sim, "7" => $satnav, "8" => $eco_plus, "9" => $eco_plus_address, "10" => $ttConnect, "11" => $ttConnect_serial, "12" => $fms, "13" => $remote_link, "14" => $remote_link_address, "15" => $remote_logbook, "16" => $remote_logbook_address, "17" => $registration, "18" => $vehicle_make, "19" => $vehicle_model, "20" => $colour, "21" => $mileage, "22" => $box_location, "23" => $comments, "24" => $ip_address));

我无法找到问题,pdo正在为项目中的其他查询工作,非常感谢帮助。

1 个答案:

答案 0 :(得分:0)

不确定这是否是它抛出该错误的原因,但你需要在你的参数数组中使用冒号

$stmt = $pdo->prepare("INSERT INTO installs (customer_id, engineer_id, datetime, tracker, tracker_serial, tracker_sim, satnav, eco_plus, eco_plus_address, ttConnect, ttConnect_address, fms, remote_link, remote_link_address, remote_logbook, remote_logbook_address, registration, vehicle_make, vehicle_model, colour, mileage, box_location, comments, ip_address) VALUES (:1,:2,:3,:4,:5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24)");
$stmt->execute(array(":1" => $customer_id, ":2" => $engineer_id, ":3" =>...etc));