绑定参数导致警告

时间:2012-09-06 23:51:02

标签: php mysqli

  

可能重复:
  Cannot use call_user_func_array on mysqli_stmt object

我有一段mysqli代码,它在这行代码中输出警告:

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

警告是:

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

以下是主要代码:

// 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"); 
}

1 个答案:

答案 0 :(得分:1)

您可以直接调用该方法:

$stmt->bind_param($referencedArray);
编辑:其实我错了。对于可变数量的参数,您需要call_user_func_array。请参阅此答案以获取解决方案:https://stackoverflow.com/a/5108167/163024