當我在頁面中多次調用一個過程時,我很難調用和顯示內容。我試圖從兩個不同的SP調用MYSQL中顯示兩個單獨的記錄集。我可以顯示第一個呼叫,但第二個呼叫失敗。我不確定我做錯了什麼,但也許有人可以幫忙?調用多個存儲過程時PHP MYSQL錯誤
我不斷收到錯誤,當我撥打第二個過程:
Error calling SPCommands out of sync; you can't run this command now
我下面
代碼Windows運行... PHP
// First call to SP
$page = 2;
$section = 1;
include("DatabaseConnection.php"); //general connection - works fine
$sql = 'CALL GetPageContent("'.$page.'", "'.$section.'")';
$result = mysqli_query($conn, $sql) or die('Error calling SP' .mysqli_error($conn));
while($row=mysqli_fetch_assoc($result))
{
// DO STUFF< REMOVED TO MAKE READING CLEARER
}
mysqli_free_result($result);
//SECOND CALL BELOW
$section = 2; // change parameter for different results
$sql = 'CALL GetPageContent("'.$page.'", "'.$section.'")';
$result = mysqli_query($conn, $sql) or die('Error calling SP' .mysqli_error($conn));
while($row=mysql_fetch_assoc($result))
{
// DO STUFF< REMOVED TO MAKE READING CLEARER
}
不應該第二次提取是'mysqli_fetch_assoc'嗎? –
是的,但無論哪種方式,我仍然得到同樣的錯誤......? thx – user1415936
這不行? http://stackoverflow.com/q/4997601/138383 –