error in running recursion

Posted by GOsha on Stack Overflow See other posts from Stack Overflow or by GOsha
Published on 2010-06-14T17:03:30Z Indexed on 2010/06/14 18:02 UTC
Read the original article Hit count: 175

Filed under:

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?

© Stack Overflow or respective owner

Related posts about php