Welcome Guest, Not a member yet? Register   Sign In
[SOLVED!]A PHP Error was encountered
#1

[eluser]maria clara[/eluser]
hi,

my console is showing this message, and i wonder what is this..
Code:
<p>Severity: Warning</p>
<p>Message:  Invalid argument supplied for foreach()</p>
<p>Filename: models/users_db.php</p>
<p>Line Number: 178</p>

it is pointing to the MODEL:
Code:
foreach ($rows as $row)
        {
            $rdata = explode('|', $row);
            
            $data['user_id'] = $id;
            $data['company_id'] = $rdata[5];            
            
            $this->db->insert('sec_companyaccess', $data);
        }

hope someone could help me with this..

thanks in advance,
maria
#2

[eluser]flaky[/eluser]
your $rows array is not correctly set up
#3

[eluser]saidai jagan[/eluser]
Code:
print_r($rows)
use before the foreach.
#4

[eluser]Sbioko[/eluser]
$rows variable must be an array.
#5

[eluser]maria clara[/eluser]
hi to all,

thanks for the advice. it still showing me the same message.


regards,
maria
#6

[eluser]saidai jagan[/eluser]
can u pls show the
Code:
print_r($rows)
result
#7

[eluser]maria clara[/eluser]
[quote author="saidai jagan" date="1262862841"]can u pls show the
Code:
print_r($rows)
result[/quote]

hi,

i already posted the solution for this, check on this: solution

thanks a lot. your script helps me.

regards,
maria Smile
#8

[eluser]Rahul Anand[/eluser]
Hi could you please send me the script to check at [email protected] or post the whole script. Al give you the solution within a minute.


Thanks
Rahul
#9

[eluser]maria clara[/eluser]
[quote author="Rahul Anand" date="1262864744"]Hi could you please send me the script to check at [email protected] or post the whole script. Al give you the solution within a minute.


Thanks
Rahul[/quote]

hi,

i already solved this but if you wish i will send you the script at your mail.

regards,
maria
#10

[eluser]maria clara[/eluser]
@rahul,

i havent done yet the detail list in my jqgrid that's why i havent used this..i just solve it for the error
Code:
invalid argument in foreach()
will not occur.

here's the script:

Code:
function save_detail($id,$rows) //Query for saving the company details
    {
        $this->db->where('user_id', $id);
        $this->db->delete('sec_companyaccess');
        
        print_r($rows); //sol for invalid argument
        foreach ($rows as $row)
        {
            $rdata = explode('|', $row);
            
            $data['user_id'] = $id;
            $data['company_id'] = $rdata[3];            
            
            $this->db->insert('sec_companyaccess', $data);
        }
    }

i cant send in your gmail..




Theme © iAndrew 2016 - Forum software by © MyBB