0

Possible Duplicate:
Cannot use call_user_func_array on mysqli_stmt object

I have a piece of mysqli code which is outputting a warning in this line of code:

if (!$stmt = $mysqli->prepare($questionquery)) {
  die("Error preparing statement: $mysqli->error"); 
}

The warning is:

Warning: Wrong parameter count for mysqli_stmt::bind_param() in ... line 80 

Below is main code:

// Make the referenced array
$referencedArray = make_values_referenced(array_merge(
  array(str_repeat("ss", $numTerms)), // types
  $termArray,                         // where
  $termArray                          // order by
));

// ...or die() is evil in production but I shall assume we are debuggin so I won't complain
if (!$stmt = $mysqli->prepare($questionquery)) {
  die("Error preparing statement: $mysqli->error"); 
}

// Bind parameters
if (!$stmt->bind_param($referencedArray)) {
  die("Error binding parameters: $stmt->error"); 
}
Community
  • 1
  • 1
user1653070
  • 39
  • 1
  • 9

1 Answers1

1

You can call the method directly:

$stmt->bind_param($referencedArray);

EDIT: Actually I'm mistaken. You need call_user_func_array for variable number of parameters. See this answer for a solution: https://stackoverflow.com/a/5108167/163024

Community
  • 1
  • 1
Matt S
  • 14,976
  • 6
  • 57
  • 76
  • Hi, I updated question to include your line of code but I now get another warning. Can you please look at my updated question, it contains more code and it contains the line of code you gave me and the new warning it has given me – user1653070 Sep 07 '12 at 00:06
  • should it be `$stmt->bind_param(array($referencedArray));? ` – user1653070 Sep 07 '12 at 00:07
  • See http://stackoverflow.com/a/5108167/163024 – Matt S Sep 07 '12 at 00:15