我正在尝试将几个参数动态传递给 bind_param() 函数。
这是我收到的错误:
警告:mysqli_stmt::bind_param() 的参数 2 应为参考,给定值
代码:
$con = new mysqli('localhost',USER,PASS,DBS);
if(mysqli_connect_errno()) {
error(mysqli_connect_errno());
}
$con -> set_charset("utf8");
/*inside*/
$type='';
$query='SELECT bugID FROM bug';
if(!empty($_GET['cena'])) {
$build[]='uCena=?';
$type.='i';
$val[]=$_GET['cena'];
}
if(!empty($_GET['popust'])) {
$build[]='uPopust=?';
$type.='i';
$val[]=$_GET['popust'];
}
if(!empty($build)) {
echo $query .= ' WHERE '.implode(' AND ',$build);
}
$new = array_merge(array($type),$val);
foreach($new as $key => $value)
{
$tmp[$key]=&$new[$key];
}
echo '<br/><br/>';
foreach ($new as $new ){
echo "$new<br/>";
}
if ($count = $con->prepare($query)) {
call_user_func_array(array($count,'bind_param'),$tmp);
$count->execute();
$cres = $count->fetch_row();
$count -> close();
} else error($con->error);
/*inside*/
$con -> close();