Connected successfully ( ! ) Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\wamp64\www\database\db.php on line 16 What I have tried: <pre><!DOCTYPE html> <html> <body> <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "db"; include("connection.php"); $sql = "SELECT id, firstname, lastname FROM myguests"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; } } else { echo "0 results"; } mysqli_close($conn); ?> </body> </html>
... if ($result = mysqli_query($conn, $sql)) { ...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)