我尝试使用预准备语句将多个值插入到mysql数据库中时出现错误。使用php编写语句插入多个值时出错
我不断收到此错误
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables.
我认为它看到$数据作为单个值,我不知道现在该做什么
$keys = (?, ?, ?);
$types = "iii";
$data = "1, 3, 500";
if ($stmt2 = $conn->prepare("INSERT INTO tranx (user, type, amount) VALUES (?, ?, ?),$keys")) {
$ortype = 1;
$stmt2->bind_param("iii".$types, $userid, $ortype, $amount, $data);
$stmt2->execute();
$stmt2->close();
}
由于它的工作..不得不调整它有点你 – joshua
是这个调整有关的代码,或只是自己的数据源?如果前者请分享,所以我可以修复答案,因为这显然是现场草图,未经测试 –
不,它关于我的数据源 – joshua