Welcome Guest, Not a member yet? Register   Sign In
What am I missing?
#1

[eluser]jshultz[/eluser]
I'm not sure what I'm missing here. If I take the if/foreach/endif block out, then everything works fine. However, if I put that block in, then I get "Fatal error: Cannot use object of type stdClass as array" on "'type' => $row['@attributes']['type']," However, like I said, if that for php block is gone then it works just fine. I even hardcoded a select block in it's place and it works ok. Am I just missing something? I have the exact same block of code in another location on the page and it's not causing any errors anywhere around it. I'm lost.


Code:
<td>&lt;?php echo form_open_multipart('/callcenter/school_submit/'); ?&gt;

                                                <div class="span-4">
                    <select name="agent">

                &lt;?php if (isset($agents) && count($agents)) : foreach ($agents->result() as $row): ?&gt;

                        <option value="&lt;?=$row->agentid?&gt;">&lt;?=$row->agent_name?&gt;</option>


                        &lt;?php endforeach ?&gt;

                &lt;?php endif ?&gt;
                    </select>
                     </div>
                                &lt;?php
                                        $data = array(
                                            'lead_number'   => $lead_number,
                                            'network'       => 'cb',
                                            'type'          => $row['@attributes']['type'],
                                            'client_id'     => $row['@attributes']['client_id'],
                                            'id'            => $row["@attributes"]["id"],
                                            'link'          => $row['link'],
                                            'source'        => $source,
                                        );
                                    echo form_hidden($data);

                                    echo form_submit('submit', 'Record Lead');
                                    echo form_close();
                                ?&gt;
                            </td>
#2

[eluser]jmadsen[/eluser]
Look above:

Code:
$row->agentid

your data is a stdObject, not an array. It looks like you changed $row midway, and messed up your data a bit.

try changing foreach ($agents->result() as $row) to foreach ($agents->result() as $agent_row); i think that will fix
#3

[eluser]jshultz[/eluser]
You know, I had almost tried that last night, but at the time I was sure that that wasn't the problem. I thought that since it was in it's own &lt;?php ?&gt; block that it would be fine. I didn't catch up above where I had opened up another if/foreach block (&lt;?php if (isset($cb_offers) && count($cb_offers)) : foreach ($cb_offers as $row): ?&gtWink and hadn't closed it yet. I should have at least tried that. Oh well, that's what I get for doing it at 9pm at night instead of just chilling out for the evening.

Thank you! Smile
#4

[eluser]jmadsen[/eluser]
no problem - only spotted it right away cuz I've done it myself ;-)




Theme © iAndrew 2016 - Forum software by © MyBB