警告:mysqli_stmt::bind_param():变量数与准备好的语句中的参数数不匹配 [英] Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement

查看:64
本文介绍了警告:mysqli_stmt::bind_param():变量数与准备好的语句中的参数数不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement

我在绑定和执行准备语句时遇到问题.与数据库的连接已成功建立,并且确实设法将其插入到具有 ?

I am having trouble binding and executing the prepare statement. The connection to the database is succesfully established and it does manage to insert it into the database with the initial value of ?

代码如下:

// 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();

推荐答案

去掉 ? 周围的引号并使用 10 个参数而不是 11 个

Lose the quotes around ? and use 10 params instead of 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);

这篇关于警告:mysqli_stmt::bind_param():变量数与准备好的语句中的参数数不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆