我正在尝试做一些调用,但第二个查询失败,并且命令'Commands out of sync;你现在不能运行这个命令'错误。当使用mysqli和预处理语句时,命令不同步
的代码看起来是这样的:
$sql="call listReport();";
$results = mysqli_query($link,$sql);
$arr=array();
while($row=mysqli_fetch_array($results)) {
array_push($arr,$row);
}
mysqli_free_result($results);
// then I have this
// but this fails, giving the above mentioned error
$stmt = @mysqli_prepare($link,"select ........") or die(mysqli_error($link));
@mysqli_stmt_bind_param($stmt, 's', $s);
@mysqli_stmt_execute($stmt);
@mysqli_stmt_bind_result($stmt, $s);
@mysqli_stmt_fetch($stmt);
@mysqli_stmt_close($stmt);
我实际使用mysqli_free_result($results);
但没有奏效。我错过了什么?
您可以使用此代码重现错误?您正在推送'$ row'来定义'$ arr',并且不使用'$ arrows'。不要用'@'来压制错误,任何错误信息都会有帮助。 (可能是一个有用的链接:[在MySQL网站上解释此错误](http://dev.mysql.com/doc/refman/5.1/en/commands-out-of-sync.html)。) – Lekensteyn 2010-09-22 13:59:48
On the第二组的第一个方法失败,die节点打印错误。 – Pentium10 2010-09-22 14:02:56