这是我要用于查询的代码:
$data=[
'e_id' => $eid,
'e_name' => $ename,
'e_deptid' => $edid,
'e_sal' => $esal,
];
foreach($data as $keys=>$values){
if($key==0){
$fields .= $keys . "=?";
} else {
$fields .= ", " . $keys . "=?";
}
$key++;
}
$query = "INSERT INTO employee SET $fields";
$stmt = $conn->prepare($query);
$stmt->bind_param(
"isii", $data['e_id'], $data['e_name'],
$data['e_deptid'], $data['e_sal']
);
我收到以下错误:
致命错误:未捕获错误:在
bind_param()
的{{1}}上调用成员函数boolean
堆栈跟踪:在第35行的C:\xampp\htdocs\employee\employeesubmit.php:35
中抛出#0 {main}。
这可能是什么原因?