【发布时间】:2014-03-18 00:58:09
【问题描述】:
我有一个触发 MySQL SP 的 PHP 脚本。 SP cmd 在直接针对 db 运行时起作用(我使用的是 PhpMyAdmin UI)。测试时,PHP 返回错误“警告:mysql_num_rows() 期望参数 1 是资源”,因为 SP 没有返回任何内容...当我调试脚本时,我看到变量 $result1 设置了所有参数为空。
在脚本中使用与此相同的代码成功执行了另一个 SP,所以我有点困惑。任何想法是什么问题?
$result1 = $mysqli->query("CALL sp_playerInvite_pin_select('samsmith@hotmail.com')");
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)不正常的情况下发生的。
-
已添加 SP。 SP 对 DB 运行有效。
-
它不是 SP AFAIKS
标签: php mysql stored-procedures phpmyadmin