gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:29:15 24 4
gpt4 key购买 nike

我正在尝试使用数组动态绑定(bind)参数。这是我的代码中很重要的部分,还显示了调试信息:

$params = array_merge( array( $one ), array_values( $two ) );
echo '<pre>';
echo $query . '<br><br>';
print_r( $params );
call_user_func_array( array( &$stmt, 'bind_param' ), MakeValuesReferenced( $params ) );

这是调试信息:

enter image description here

正如您所看到的,我的查询中有三个问号,并且在bind_param 中添加了三个参数。我认为这应该有效。我做错了什么?

最佳答案

您不能引用占位符,这会使其成为文字值而不是占位符。将时间移至绑定(bind)中并保留占位符。

例如

where thedateandtime between ? and ?

然后在绑定(bind)中

($date . ' 00:00:00')

您也无法绑定(bind)列,因此应更改order by。在将值传递到查询之前使用白名单来比较值。

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

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