I am trying to output(show) some values from my database then later get my hands dirty on with it.
I wrote a custom code with mysqli but each time I run the page it gives me error mesage saying :
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\christembassy\controlscript.php on line 30
the line 30 on my code is this : if(mysqli_num_rows($result) > 0)
And this is the whole code:
<?php
//setting connection variables
$hostname = "localhost";
$username= "root";
$password ="";
$db= "cemembers";
//opening connection go database
$mysqli_db = mysqli_connect($hostname, $username, $password, $db);
//check connection
if(mysqli_connect_errno()) {
printf("Connect Failed: %s\n", mysqli_connect_errno());
exit();
}
$sql = "SELECT FristName, LastName, Occupation FROM users";
$result = mysqli_query($mysqli_db, $sql);
if(mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo ' Name: $row["FirstName"]. $row["LastName"] ."<br>" Cell: $row["Occupation"]'."<br>";
}
} else {
echo(" 0 Results found");
}
mysqli_close($mysqli_db);
?>
Please any help would be much appreciated.