我正在为我已经运行的mysqli查询实现准备好的语句。我遇到了一行if(mysqli_num_rows($result) == 0)
,因为它现在是一个字符串而不是一个mysqli_result。
if($nameAvailableStmt = mysqli_prepare($link, 'SELECT name FROM usetbl1 WHERE name=? LIMIT 1'))
{
mysqli_stmt_bind_param($nameAvailableStmt, "s", $_POST['dangerous']);
mysqli_stmt_execute($nameAvailableStmt);
mysqli_stmt_bind_result($nameAvailableStmt, $result);
mysqli_stmt_fetch($nameAvailableStmt);
}
if(mysqli_num_rows($result) == 0)
答案 0 :(得分:3)
应该是:
mysqli_stmt_store_result($nameAvailableStmt);
if(mysqli_stmt_num_rows($nameAvailableStmt) == 0)