2

I'm implementing prepared statements on my already working mysqli queries. I'm having trouble with a line if(mysqli_num_rows($result) == 0) as it's now a string instead of a 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)
Celeritas
  • 14,489
  • 36
  • 113
  • 194

1 Answers1

3

It should be:

mysqli_stmt_store_result($nameAvailableStmt);
if(mysqli_stmt_num_rows($nameAvailableStmt) == 0)

See the Documentation

Barmar
  • 741,623
  • 53
  • 500
  • 612