Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:52:09+00:00 2026-06-13T00:52:09+00:00

I’m trying to figure out why I keep getting a few trying to get

  • 0

I’m trying to figure out why I keep getting a few trying to get property of non object errors. with the array that I have created. I created the array and am foreaching it out and by the looks of my object array those properties do exist.

I am getting the errors in this area:

// Separates each of the last 5 pesonal messages
foreach ($last_5_personal_messages AS $message)
{
    echo '<li>';
    echo '<span class="icon avatar"><img src="'.$message->sender_avatar.'" alt="" /></span>';
    echo '<span class="name"><a href="'.$site_url.'/personalmessages/viewmessage/'.$message->message_id.'"><strong>'.$message->sender_name.'</strong></a><span class="time">'.$message->datetime_sent.' ago</span></span>';
    echo '<span class="msg">'.$message->subject.'</span>';
    echo '</li>';
}
?>


Array
(
[0] => stdClass Object
    (
        [message_id] => 1
        [subject] => Test Message
        [datetime_sent] => 2 weeks
        [attachments] => 
        [priority] => 0
        [message_content] => Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        [message_read] => 0
        [is_favorite] => 0
        [sender_name] => Mike Scott
        [sender_email_address] => myemail@myemail.com
        [sender_avatar] => http://dev.myserver.com/assets/themes/supr/images/avatars/avatar5.jpg
    )

[1] => stdClass Object
    (
        [message_id] => 2
        [subject] => Testing PM Message
        [datetime_sent] => 3 weeks
        [attachments] => Array
            (
                [0] => Array
                    (
                        [file_name] => file1.jpg
                        [is_file] => 1
                        [file_size] => 7.01 KB
                        [file_location] => assets/downloads/file1.jpg
                    )

                [1] => Array
                    (
                        [file_name] => file2.jpg
                        [is_file] => 
                    )

                [2] => Array
                    (
                        [file_name] => file3.jpg
                        [is_file] => 
                    )

            )

        [priority] => 0
        [message_content] => This is jsut a test of the personal message system!
        [message_read] => 0
        [is_favorite] => 0
        [sender_name] => Kevin Scott
        [sender_email_address] => myemail@server.com
        [sender_avatar] => http://dev.myserver.com/assets/themes/supr/images/avatars/avatar5.jpg
    )

[2] => stdClass Object
    (
        [message_id] => 3
        [subject] => Testing Whatever
        [datetime_sent] => 1 week
        [attachments] => 
        [priority] => 0
        [message_content] => Testing Message Content
        [message_read] => 0
        [is_favorite] => 0
        [sender_name] => Frank Scott
        [sender_email_address] => frankscott@testemail.com
        [sender_avatar] => http://dev.myserver.com/assets/themes/supr/images/avatars/avatar.jpg
    )

[total_unread_messages] => 3
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:52:11+00:00Added an answer on June 13, 2026 at 12:52 am

    GBD is right, it’s because the total_unread_messages key does not contain an object as its value, so you get this warning.

    You can also iterate over that array manually, using the information within total_unread_messages to your advantage, if you don’t want to have that if( is_object()) check on every loop iteration. Something like this should work:

    for( $i = 0; $i < $last_5_personal_messages['total_unread_messages'] && $i < 5; $i++) {
        $message = $last_5_personal_messages[$i];
         echo '<li>';
         // ....
    }
    

    Or you can unset() that value before you iterate (and optionally put it back when you’re done):

    unset( $last_5_personal_messages['total_unread_messages']);
    foreach( $last_5_personal_messages as $message) {
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.