You are probably getting an error message like
mysqli_stmt::bind_param() expected to be a reference, value given in...
The problem is that bind_param()
in PHP 5.3+ requires array values as reference while 5.2 works with real values.
From the docs:
Care must be taken when using mysqli_stmt_bind_param() in conjunction with call_user_func_array(). Note that mysqli_stmt_bind_param() requires parameters to be passed by reference, whereas call_user_func_array() can accept as a parameter a list of variables that can represent references or values (ref).
One solution is to create an array of references
$params = array("i", 2);
$tmp = array();
foreach($params as $key => $value) {
$tmp[$key] = &$params[$key];
}
call_user_func_array(array($stmt, 'bind_param'), $tmp);
and another similar solution is
function refValues($arr){
if (strnatcmp(phpversion(),'5.3') >= 0) //Reference is required for PHP 5.3+
{
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
return $arr;
}
$params = array("i", 2);
call_user_func_array(array($stmt, 'bind_param'), refValues($params));