类型定义字符串中的元素数量与第8行的/home/a3598479/public_html/Register.php中的绑定变量数量不匹配 [英] Number of elements in type definition string doesn't match number of bind variables in /home/a3598479/public_html/Register.php on line 8
本文介绍了类型定义字符串中的元素数量与第8行的/home/a3598479/public_html/Register.php中的绑定变量数量不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我.我实际上并没有使用PHP,但是需要在我的Login/Register项目中使用.
Please help me. I don't actually use PHP but I need to use in my Login/Register project.
$con = mysqli_connect("***", "***", "***", "***");
$name = $_POST["name"];
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "INSERT INTO user (name, username, password) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($statement, "siss", $name, $username, $password);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
但它说
Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]: Number of elements in type definition string doesn't match number of bind variables in /home/a3598479/public_html/Register.php on line 8
我该如何解决?
推荐答案
我认为以下语句存在问题:
I think problem in following statement:
mysqli_stmt_bind_param($statement, "siss", $name, $username, $password);
您正在传递siss
,这意味着应该有4个params
,其类型为string
,integer
,string
和string
,这是错误的,因为只有three parameters
都是字符串
You are passing siss
which means it there should be 4 params
with types string
, integer
, string
and string
which is wrong as you have only three parameters
which are all string.
所以声明应该像这样:
mysqli_stmt_bind_param($statement, "sss", $name, $username, $password);
这篇关于类型定义字符串中的元素数量与第8行的/home/a3598479/public_html/Register.php中的绑定变量数量不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文