gpt4 book ai didi

PHP 命令不同步错误

转载 作者:可可西里 更新时间:2023-11-01 06:37:34 24 4
gpt4 key购买 nike

这个简单的代码调用了两个 MySQL 过程,但在第一个返回值之后,它在第二个查询中返回错误。

注意:单独运行第一个或第二个将正确返回每个。所以查询有效,只是不在一起。

完整的错误是:无效查询:命令不同步;你现在不能运行这个命令

请有任何想法。

<?php

require_once ('connection.php');
//First Query and Output

$result = mysql_query("CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while($row=mysql_fetch_array($result))
{
echo $row['CommisionPercentage'];
}

mysql_free_result($result);
//END First Query and Output

//Second Query and Output
$new2 = mysql_query("CALL C01_Client_Summary_ByBetType(1, '2012-02-27', '2013-03-29');");
if (!$new2) {
die('Invalid query: ' . mysql_error());
}
while($row=mysql_fetch_array($new2))
{
echo $row['Turnover'];
}
//END Second Query and Output

?>

最佳答案

用于 PHP 的旧 MySQL 扩展无法与存储过程一起正常工作。不幸的是,没有办法用它来执行多个存储过程。问题是第一个过程留下了一些缓冲的结果集,导致第二个过程失败。但是,您可以使用 mysqli 扩展。这是一个很好的例子,说明如何做到这一点:

http://www.daniweb.com/web-development/php/threads/234868/error-commands-out-of-sync-you-cant-run-this-command-now

关于PHP 命令不同步错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15373698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com