error in running recursion
- by GOsha
if running function returns server misconfiguration error
function build_path($cid)
{
$result = array();
$DB = new MySQLTable;
$DB->TblName = 'shop_categories';
$where['cat_id']['='] = $DB->CleanQuest($cid);
$res = $DB->Select('cat_id,cat_name,cat_parent', $where);
if($res !== 'false')
{
$pid = mysql_fetch_array($res);
if($pid['cat_parent'] !== 0)
{
Echo $pid['cat_parent'];
build_path($pid['cat_parent']);
} else {
Echo $pid['cat_id'];
return true;
}
}
return false;
}
I can't find an error here. Please help.
Sorry for disturbing you all. The trouble was in comparison 'if($pid['cat_parent'] !== 0)': $pid['cat_parent'] was a string with int(0)
Can i build this function to store full path without using GLOBALS and SESSION vars?