1

Anyone has any idea how to count the amount of rows retrieved? It should only be 1 in this case- but I just can't seem to make it work with prepared statements (still very new to using it)

Thanks in advance for any help!

if ($stmt = $db->prepare("SELECT playername FROM player_data
                        WHERE playername = ?"))
{   
    $stmt->bind_param("s", $_GET["target"]);
    $stmt->execute();
    $stmt->bind_result($playername);

    $stmt->fetch();

    $row_cnt = $stmt->num_rows();

    printf("Result set has %s rows.\n", $row_cnt);

    $stmt->close(); 
}
else 
{
    printf("Error: %s", $mysqli->error);
}

0 Answers0