NUM_ROWS not working in webhost

$countLowStocks = $query->num_rows;

the above code is not working it shows an error of :

Notice: Trying to get property of non-object in /storage/ssd5/426/2820426/public_html/dashboard.php on line 11

PLEASE HELP ME ASAP

Hi @jhekcuenca28!

Please post your entire script so we can debug it.

Hi @jhekcuenca28

Problem is with your query. Normally, php mysqli query functions returns false in case of any error. So, when $query has a boolean value. Thereafter if you use $query -> num_rows it will throw above error.

You can easily find the problem with adding following code before the above mentioned code

if (!$query) echo $mysqli -> error

replave $mysqli with your DB variable.

Thanks. :slightly_smiling_face:

1 Like

$sql1 = “SELECT * FROM tbl_pending WHERE status = 0”;
$query1 = $connect->query($sql1);
$countPending = count($query1);

the above code is my whole code in getting the rows affected because i wanted to display the number of pending in my table pls help me