我收到以下错误:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
我无法绑定并执行prepare语句。已成功建立与数据库的连接,并确实将其插入到数据库中,初始值为?
以下是代码:
// Set up the query
$insert = "INSERT INTO record_user (ip,country,address,stack,skills,employment_type,city_selection,landing_time,submission_time,time_spent)
VALUES ('?','?','?','?','?','?','?','?','?','?')";
// Prepare the statement
$insert = $con->prepare($insert);
// Bind the statement
$insert->bind_param("ssssssssss", $user_ip, $country, $location, $stack, $skills, $employment, $city, $landing_time, $submission_time, $time_spent);
// Execute the statement
$insert->execute();
// Close the statement connection
$insert->close();
// Close the database connection
$con->close();
答案 0 :(得分:1)
丢失?
周围的引号并使用10个参数而不是11个
而不是:
$insert = "INSERT INTO record_user (ip,country,address,stack,skills,employment_type,city_selection,landing_time,submission_time,time_spent)
VALUES ('?','?','?','?','?','?','?','?','?','?')";
$insert = $con->prepare($insert);
$insert->bind_param("ssssssssss", $user_ip, $country, $location, $stack, $skills, $employment, $city, $landing_time, $submission_time, $time_spent);
试试这个:
$insert = "INSERT INTO record_user (ip,country,address,stack,skills,employment_type,city_selection,landing_time,submission_time,time_spent)
VALUES (?,?,?,?,?,?,?,?,?,?)";
$insert = $con->prepare($insert);
$insert->bind_param("ssssssssss", $user_ip, $country, $location, $stack, $skills, $employment, $city, $landing_time, $submission_time, $time_spent);
答案 1 :(得分:0)
您准备好的查询没有任何占位符。您正在向数据库中插入10个文字 ?
个字符。
您需要丢失?
s周围的引号:
$insert = "INSERT INTO record_user (ip,country,address,stack,skills,employment_type,city_selection,landing_time,submission_time,time_spent)
VALUES (?,?,?,?,?,?,?,?,?,?)";