0
我有一個PHP腳本,它觸發了一個MySQL SP。 SP cmd在直接針對db運行時工作(我正在使用PhpMyAdmin UI)。當測試時,PHP返回錯誤'警告:mysql_num_rows()期望參數1是資源'由於事實上沒有任何返回從SP ...當我調試腳本我看到變量$ result1具有其所有參數設置爲空。PHP MySql查詢執行時出錯SP
還有另一個SP在腳本之上使用相同的代碼成功執行,所以我有點困惑。任何想法是什麼問題?
$result1 = $mysqli->query("CALL sp_playerInvite_pin_select('[email protected]')");
if(!$result1) die("CALL failed: (" . $mysqli->errno . ") " . $mysqli->error);
//echo json_encode($getPlayerInvitePin);
// check for empty result, if not then there is >1 pin corresponding to email
if (mysql_num_rows($result1) > 0)
{
//looping through all results-in theory should only 1 result
while ($row = mysql_fetch_array($result1))
{
$response["pin"] = $row["player_pin"];
}
// echoing JSON response
echo json_encode($response);
}
的SP ...
你應該顯示你的'sp' –
的代碼不應該是'mysqli_num_rows'?你的'if'沒有正確關閉。 –
您發現的錯誤通常發生在查詢(SQL)不正常時。 –