This is the code:
function getCategoryTree($level = 0, $prefix = '')
{
//$sqll = "SELECT * FROM expense_categories WHERE master_category = ".$level." GROUP BY category_id ORDER BY category ASC";
echo $db."<br/><br/>\n";
$result=mysqli_query($db,"SELECT * FROM expense_categories WHERE master_category = '$level' GROUP BY category_id ORDER BY category ASC"); //Linea 51
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result)){
$category .= $prefix . $row['category']."~~".$row['category_id'] . "<br>";
//$categories[$row->category_id] = $prefix .$row->category_name;
// Append subcategories
$category .=getCategoryTree($row['category_id'], $prefix . '>');
}
}
return $category;
}
The error:
PHP Notice: Undefined variable: db in /var/www/misitio.org/cc/config.inc on line 51
I do not understand why this happens, if the variable is declared in the connection file: dbase.inc
<?php
#################CONFIGURATION FILE##############################
define("TEMPLATES", "templates/");
## EXPENSE Categories
$expense_categories = array('Gas', 'Travel', 'Food');
##Usually this is just localhost
$host = 'localhost';
## enter mysqli username
$user = 'root';
## enter mysqli password
$pass = 'toor';
## enter databse name
$database = 'rootdb';
## start Database
$db = mysqli_connect($host, $user, $pass)
or die("Could not connect: " . mysqli_error());
mysqli_select_db($db, $database);
function mysqli_fetch_array_r($result, $index_row = "", $fetch = mysqli_ASSOC){
$n = 0;
while ($row = mysqli_fetch_array($result,$fetch)){
$hold_arr= &$whole_result[$row[$index_row]];
$hold_arr[]=$row;
}
return $whole_result;
}
extract($_REQUEST);
?>
And this is included in the TOP of the config.inc file that is where the error originates
<?php
include('dbase.inc');
global $db;