I wanna add dynamically variables to mysqli:bind_param ...
I saw a lot of tutorials and examples but the code I made isn't working for hours now.
$params = array('');
$params[0] = $variableType; //variableType contains e.g. sssi
foreach ( $data as $key => $value ) {
array_push($params, $data[$key]); // I also tried $params[] = $value;
}
call_user_func_array(array($stmt, 'bind_param'), $this->refValues($params));
The refValues function looks like this ...
private function refValues(Array &$arr)
{
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
Error given every time I try it ...
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in C:\Users...xxx.php on line 54