The call to mysqli_prepare() is likely failing, returning a boolean. You need to check to see if mysqli_prepare() actually returns a mysqli_stmt object before trying to use it.
$query = mysqli_prepare($res, $my_query);
if (!$query) {
throw new Exception('Error in preparing statement: ' . mysqli_error($res));
}
foreach($data as $key => $value){
$data[$key] = &$data[$key];
}
call_user_func_array(array($query, 'bind_param'), $data);
mysqli_stmt_execute($query);
mysqli_stmt_close($query);
Without this check, $query may be a boolean, which will of course not create a valid callback when used in the array passed to call_user_func_array().
Furthermore, I would also recommend using the OO style when utilizing mysqli.
$connection = new mysqli('host', 'username', 'password');
$statement = $connection->prepare($my_query);
if (!$statement) {
throw new Exception('Error in preparing statement: ' . $connection->error);
}
foreach($data as $key => $value){
$data[$key] = &$data[$key];
}
call_user_func_array([$statment, 'bind_param'], $data);
$statement->execute();
$statement->close();
var_dump($query)give you?call_user_func_array