Codeigniter Error - Undefined property: stdClass::$packageid

Hi,

I would like to request an assistant.

It seems that i encounter error as follows :


---------------------------------------------
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$packageid

Filename: models/home_model.php

Line Number: 239
----------------------------------------------

I believe it was due to the following function :

function get_package_id_where($config_id)

I have ensure that $config_id carry variable as i have print it and it shows correctly.

Can anybody spot the error in the code ?

Can help to adjust it ? for me to try ?


The following is the code.




     

    function get_optionname_awbs($id) {

        $awbs = $this->load->database('default', TRUE);
        $q = $awbs->query('SELECT type FROM hosting_addons WHERE id = ' . $id . '');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->type;
            }
        } else
            return 0;
    }


     function awbs_group_configoptions_name($awbs_addon_type) {

        $awbs = $this->load->database('default', TRUE);
        $q = $awbs->query('SELECT description FROM hosting_addon_types WHERE type = ' . $awbs_addon_type . '');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->description;
            }
        } else
            return 0;
    }
 
     function get_package_id_where($config_id) {
        
        $whmcs = $this->load->database('whmcs', TRUE);
        $q = $whmcs->query('SELECT awbsid FROM tblhosting WHERE id = ' . $config_id . '');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->packageid; // <<< This is where the line shows error .
              
            }
        } else return 0;   
    }

     function get_group_id_where($package_id) {
        
        $whmcs = $this->load->database('whmcs', TRUE);
        $q = $whmcs->query('SELECT gid FROM tblproductconfiglinks WHERE pid = ' . $package_id . '');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->gid;
            }
        } else return 0;   
    }
    
     function get_tblproductconfigoptions_id($group_id, $optionname) {
        
        $whmcs = $this->load->database('whmcs', TRUE);
        $q = $whmcs->query('SELECT id FROM tblproductconfigoptions WHERE gid = ' . $group_id . ' AND optionname = "' . $optionname . '"');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->id;
            }
        } else return 0;   
    }


      function get_id_from_tblproductconfigoptionssub($group_config_id, $awbs_addon_name) {
        
        $whmcs = $this->load->database('whmcs', TRUE);
        $q = $whmcs->query('SELECT id FROM tblproductconfigoptionssub WHERE configid = ' . $group_config_id . ' AND optionname = "' . $awbs_addon_name . '"');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->id;
            }
        } else return 0;   
    }
    




        foreach ($addonlist as $key => $value) {

            $if_dedicated = strpos($value["parent_id"], 'D');
            
            //$str_replace_package_id = str_replace('D', '', $value["parent_id"]);

            if ($if_dedicated !== false) {
            
                $str_replace_dedicated = str_replace('D', '', $value["parent_id"]);
            
                
                $tblhostingconfigoptions[$key]['relid'] = $str_replace_dedicated;
                

                $tblhostingconfigoptions[$key]['qty'] = $value["qty"];
                
                //name of the addon awbs
                $awbs_addon_name = $value["name"];
                
                //type addon awbs
                $awbs_addon_type = $this->get_optionname_awbs($value["itemid"]);

                //group name configoptions
                $awbs_group_configoptions_name = $this->awbs_group_configoptions_name($awbs_addon_type);
                
                //package which uses the hosting client
                
                $package_id = $this->get_package_id_where($tblhostingconfigoptions[$key]['relid']);
                
                //group configoptions
                $group_id = $this->get_group_id_where($package_id);
                
                $group_config_id = $this->get_tblproductconfigoptions_id($group_id, $awbs_group_configoptions_name);
                
                $tblhostingconfigoptions[$key]['configid'] = $group_config_id;
                
                $optionid = $this->get_id_from_tblproductconfigoptionssub($group_config_id, $awbs_addon_name);
                $tblhostingconfigoptions[$key]['optionid'] = $optionid;
                
                $whmcs->insert('tblhostingconfigoptions', $tblhostingconfigoptions[$key]);
            }
        }

Open in new window




Thank you.
LVL 2
Shamsul KamalJunior TechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Let's look at just this part.  The SELECT query asks for awbsid, but it would need to ask for packageid to get that field in the query results set.
     function get_package_id_where($config_id) {
        
        $whmcs = $this->load->database('whmcs', TRUE);
        $q = $whmcs->query('SELECT awbsid FROM tblhosting WHERE id = ' . $config_id . '');

        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                return $row->packageid; // <<< This is where the line shows error .
            }
        } else return 0;   
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shamsul KamalJunior TechAuthor Commented:
Very good !
0
Ray PaseurCommented:
Thanks for the points!  Best of luck with your project, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.