I am getting a Notice: Trying to get property of non-object in the line if ($resCategory->num_rows > 0). May I know what is the mistake here?
<?php
function categoryParentChildTree($parent = 'L1', $spacing = '', $category_tree_array = '') {
global $MySQLi_CON;
$parent = $MySQLi_CON->real_escape_string($parent);
if (!is_array($category_tree_array))
$category_tree_array = array();
$sqlCategory = "SELECT * FROM users where enrolled_id = $parent ORDER BY enrolled_id ASC";
$resCategory=$MySQLi_CON->query($sqlCategory);
if ($resCategory->num_rows > 0) {
while($rowCategories = $resCategory->fetch_assoc()) {
$category_tree_array[] = array("id" => $rowCategories['enroller_id'], "name" => $spacing . $rowCategories['user_name']);
$category_tree_array = categoryParentChildTree($rowCategories['enroller_id'], ' '.$spacing . '- ', $category_tree_array);
}
}
return $category_tree_array;
}
?>