gpt4 book ai didi

mysqli_stmt::bind_param():变量数量与 mysql php 中准备好的语句中的参数数量不匹配

转载 作者:行者123 更新时间:2023-11-29 19:49:10 26 4
gpt4 key购买 nike

我正在使用准备好的语句并执行

$search = trim($_GET['s']);
if($stmtgetproducts = $mysqli->prepare("SELECT s.store_id, product_id, product_name, product_desc, product_price, product_discount, product_views, product_date, product_code, product_category, product_image1, product_image2, sale_id,s.store_name,s.store_username
FROM store_products sp
INNER JOIN store_product_categories spc ON sp.product_category=spc.id
INNER JOIN store s ON sp.store_id=s.store_id WHERE MATCH(product_name, product_desc) AGAINST('?' IN BOOLEAN MODE);")){
$stmtgetproducts->bind_param("s",$search);
$stmtgetproducts->execute();
$getproducts=$stmtgetproducts->get_result();
$stmtgetproducts->close();
}
else
{
echo $mysqli->error;
}

因为,我只给它一个参数作为参数,并且绑定(bind)参数只是一个 $search 它给了我这个错误

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

这个 if 表单

<form action="" method="GET">
Search Product: <input type="text" name="s" placeholder="Enter product name">
</form>

如果我改变这个

$stmtgetproducts->bind_param("ss",$search);

然后就出现这个错误

mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 

最佳答案

$stmtgetproducts = $mysqli->prepare("SELECT s.store_id, product_id, product_name, product_desc, product_price, product_discount, product_views, product_date, product_code, product_category, product_image1, product_image2, sale_id,s.store_name,s.store_username 
FROM store_products sp
INNER JOIN store_product_categories spc ON sp.product_category=spc.id
INNER JOIN store s ON sp.store_id=s.store_id WHERE MATCH(product_name, product_desc) AGAINST(? IN BOOLEAN MODE);"))

将我准备好的声明更改为此

关于mysqli_stmt::bind_param():变量数量与 mysql php 中准备好的语句中的参数数量不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40869603/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com