Welcome Guest, Not a member yet? Register   Sign In
Invalid argument supplied for foreach()
#1

[eluser]Corbee[/eluser]
Hi,

I kept getting error in my controller

Code:
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: controllers/register.php

Line Number: 316

but I can't seem to find the error. I used print_r to check if the model is functioning and I got the results

Code:
Array ( [0] => Array ( [vid] => 5 [sessionid] => 035153f140ea45767702b3c88ecc4d21 [regname] => asdf [regaddress] => asdf asdf asd asfd [year] => 2010 [brand] => 23 [model] => 831 [platenum] => asf-123 [motornum] => fasdf-12f3212 [chassisnum] => fdsa124123asd [mvfnum] => 4151-123412 [color] => red [aog] => no [tpl] => yes [delivery] => gma [mortgator] => 0 [insurance] => 2 [carType] => cv [price] => 6715000.00 [coverage] => 75000 ) )

Here is my controller
Code:
function vedit($vid=0)
    {
        $sessionid = getSessionID();        
        
        //get the info of the vid
        $q = $this->MRegister->getguestvid($sessionid,$vid);        
        if (count($q > 0))
        {
            foreach ($q as $key => $list)
            {        
                $data['pabrandID'] = $list['brand'];
                $data['pamodelID'] = $list['model'];
                $year = $list['year'];
                $brandID = $list['brand'];
            }
        }
        $data['vinfo'] = $this->MRegister->getguestvid($vid,$sessionid);
        $data['qyear'] = $this->MCars->getcaryear();
        $data['qbrand'] = $this->MCars->getcarbrands($year);
        $data['qmodel'] = $this->MCars->getcarmodel($year,$brandID);
        //$data[''] = $this->MCars->getcoverage();
        $this->load->view('reg_editcar',$data);
    }

my model
Code:
function getguestvid($vid='',$sessionid='')
    {
        $this->db->where('vid',id_clean($vid));
        $this->db->where('sessionid',db_clean($sessionid,32));
        $q = $this->db->get('tmp_guestvinfo');
        
        if ($q->num_rows() > 0)
        {
            foreach ($q->result_array() as $row)
            {
                $data[] = $row;    
            }    
            $q->free_result();
            print_r($data);
            return $data;
            
        }        
    }

Does anyone have an idea where it went wrong. Thanks


Messages In This Thread
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 07:35 PM
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 07:40 PM
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 08:09 PM
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 08:33 PM
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 08:41 PM
Invalid argument supplied for foreach() - by El Forum - 09-15-2010, 09:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB