"trying to get property of non object" exception?
<p>I'm trying to figure out I keept getting "trying to get property of non object in my view file. It says its an object in the print r function I ran on the $messages variable but yet it still says that error message.</p>

<pre><code>Array ( 
[0] =&gt; stdClass Object ( 
    [id] =&gt; 1 [subject] =&gt; Testing Message 1 
    [firstName] =&gt; Jeffrey 
    [lastName] =&gt; Davidson 
    [dateSent] =&gt; April 1st, 2012 
    [messageRead] =&gt; 0 )
[1] =&gt; stdClass Object ( 
    [id] =&gt; 1 [subject] =&gt; Testing Message 1 
    [firstName] =&gt; Jeffrey 
    [lastName] =&gt; Davidson 
    [dateSent] =&gt; April 1st, 2012 
    [messageRead] =&gt; 0 ) ) 


&lt;?php if (!is_null($messages[0])) { 
                    foreach ($messages[0] AS $message) { 
                        echo '&lt;tr&gt;'; echo '&lt;td style="text-align: center"&gt;'; switch ($message-&gt;
                    messageRead) { case 0: echo '
                    &lt;img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail.png /&gt;
                    '; break; case 1: echo '
                    &lt;img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail-open.png /&gt;
                    '; break; case 2: echo '
                    &lt;img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail-reply.png /&gt;
                    '; break; case 3: echo '
                    &lt;img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail-forward.png /&gt;
                    '; break; } echo '
                    &lt;/td&gt;
                    '; echo '
                    &lt;td&gt;
                        '.$message-&gt;dateSent.'
                    &lt;/td&gt;
                    '; echo '
                    &lt;td&gt;
                        &lt;a href='.base_url().'pmsystem/viewmessage/ '.$message-&gt;id.'&gt;'.$message-&gt;subject.'&lt;/a&gt;
                    &lt;/td&gt;
                    '; echo '
                    &lt;td&gt;
                        '.$message-&gt;firstName.' '.$message-&gt;lastName.'
                    &lt;/td&gt;
                    '; echo '
                    &lt;td style="text-align: center"&gt;
                        '; $data = array('name' =&gt; 'message_id', 'class' =&gt; 'messages', 'value' =&gt; $message-&gt;id); echo form_checkbox($data); echo '
                    &lt;/td&gt;
                    '; echo '
                    &lt;/tr&gt;
                    '; } } ?&gt;
</code></pre>
