php - mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean means what and how can it be fixed? -


i trying output(show) values database later hands dirty on it.

i wrote custom code mysqli each time run page gives me error mesage saying :

warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\christembassy\controlscript.php on line 30

the line 30 on code : if(mysqli_num_rows($result) > 0)

and 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 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 appreciated.

select fristname, lastname, occupation users 

99% sure meant,

select firstname, lastname, occupation users 

take care of typos.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -