Hi! I have a problem with binding parameters dynamically in my mysqli_stmt objects. As I don't know how many parameters which will be put into this function I must bind the parameters dynamically. Though I cannot understand what's wrong with this method:
public function execute($unprp_stmt, $data){
//Prepare the stmt
$stmt = $this->con->prepare($unprp_stmt);
//Get dynamically built parameter string for the bind_param method. E.g. 'issis'
$paramstr = $this->get_paramstr($data);
// Dynamically build up the arguments for bind_param
$params = array();
array_unshift($params, $stmt, $data, $paramstr);
print_r($params);
// and then call bind_param with the proper arguments
call_user_func_array('mysqli_stmt_bind_param', $params);
}
Out of this I get the following error:
Output of print_r:
Array ( [0] => mysqli_stmt Object ( [affected_rows] => -1 [insert_id] => 0 [num_rows] => 0 [param_count] => 1 [field_count] => 6 [errno] => 0 [error] => [sqlstate] => 00000 [id] => 1 ) [1] => i [2] => 1 )
And the following error:
[B]Warning:[/B] Parameter 3 to mysqli_stmt_bind_param() expected to be a reference, value given in C:\xampp\htdocs\HTSIBWORT\gw_fetcher.php on line 27
as we can see in the output from print_r is the value of parameter 3 = 1.
Why doesn't this work? Please help me out!