I have been trying to use call_user_func_array()
but dont seem to get it right.
$sql_sentence = "SELECT * FROM test_table WHERE Fag = ? AND (" . $sql_subject . ") AND (" . $sql_grade . ") AND (" . $sql_type . ")";
$sql = $conn->prepare($sql_sentence);
$allarrays = array_merge(array('ssss'),array($_POST['Fag']),$_POST['subject'],$_POST['Grade'],$_POST['Type']);
//testing to see if it prints out right values of array.
for ($x = 0; $x < count($allarrays); $x++) {
echo "The number $x is $allarrays[$x] <br>";
}
call_user_func_array(array($sql, "bind_param"),$allarrays);
$sql->execute();
But I get this error Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, and it points it to line call_user_func...
.
When I print out the SQL sentence it looks like this:
SELECT * FROM test_table WHERE Fag = ? AND (Subject LIKE ?) AND (Grade LIKE ?) AND (Type LIKE ?)
and all array-values are right, and the first array value is 'ssss', and after the first array comes four arrays with different values.
Have I done anything wrong here? Do you need more code?
EDIT: Can you open this question. I found an answer which was different than the similar question! Think it should be printed here.