Php 尝试获取存储过程结果时出错,但普通查询工作正常

Php 尝试获取存储过程结果时出错,但普通查询工作正常,php,mysql,stored-procedures,Php,Mysql,Stored Procedures,我正在尝试将结果集放入数组中。。因此,我做了以下尝试,结果是成功的 while($row = mysql_fetch_array($table_count)){ $table = $row["TABLE_NAME"]; foreach ($tables as $table) { $excute = mysql_query(" SELECT DISTINCT b.ID, name, accountname, c.accountID, status, tota

我正在尝试将结果集放入数组中。。因此,我做了以下尝试,结果是成功的

while($row = mysql_fetch_array($table_count)){
$table = $row["TABLE_NAME"];

foreach ($tables as $table) {
         $excute = mysql_query("
         SELECT  DISTINCT b.ID, name, accountname, c.accountID, status, total_impr, min(a.timestamp), max(a.timestamp)
         FROM    ",table_1," a INNER JOIN bookers b on a.ID = b.ID INNER JOIN accounts c on b.accountID = c.accountID
         WHERE   a.timestamp > DATE_ADD(NOW(), INTERVAL -1 YEAR)
         GROUP BY ID;") or die(mysql_error());
         $result = mysql_fetch_assoc($excute);
         var_dump($result);
     }  
然后为了提高代码的质量,我将该查询包含在存储过程中。。。之后,当我调用下面这样的存储过程时,它会给出一个错误,即

Commands out of sync; you can't run this command now
代码

while($row = mysql_fetch_array($table_count)){
    $table = $row["TABLE_NAME"];

foreach ($tables as $table) {
     $excute = mysql_query("CALL mySP_1('$table')") or die(mysql_error());
     $result = mysql_fetch_assoc($excute);
     var_dump($result);
 } 
存储过程

BEGIN   

SET @sqlstring = CONCAT("
SELECT  DISTINCT b.ID, name, accountname, c.accountID, status, total_impr, min(a.timestamp), max(a.timestamp)
FROM    ",table_1," a INNER JOIN bookers b on a.ID = b.ID INNER JOIN accounts c on b.accountID = c.accountID

WHERE   a.timestamp > DATE_ADD(NOW(), INTERVAL -1 YEAR)
GROUP BY ID;");
    PREPARE stmt FROM @sqlstring;
    EXECUTE stmt;

END$$
任何人都能发现为什么它在正常查询中工作正常,但在存储过程中返回错误。。我一直试图解决这个问题有一段时间,但没有任何效果


有谁能帮我解决这个问题,让我使用存储过程

存储过程不能使用Mysql_*函数


请切换到。

您能告诉我如何在这个特定实例中使用它吗