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 9177305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:17:42+00:00 2026-06-17T17:17:42+00:00

From my database I get only one result. Nevertheless I get an array returned

  • 0

From my database I get only one result. Nevertheless I get an array returned because of this code

while($obj = $stmt->fetch(PDO::FETCH_OBJ)){
    $result[] = $obj;
}

The returned array has only one element (object) at the index 0. From this object I want access a property.

My code looks like:

return $result[0]->_id;

I get the notice

Trying to get property of non-object in …

Here are my dumps:

var_dump

array(1) { [0]=> object(stdClass)#4 (13) { ["_id"]=> string(8) "43001613" ["another-property"]=> string(5) "20608" } }

print_r

Array
(
    [0] => stdClass Object
        (
            [_id] => 43001613
            [another-property] => 20608
        )

)

It is for sure only a small error but I can’t figure it out now.

Edit:
Here is the full function:

public function getOrtIDForPLZ($plz){
    $sql = "SELECT * FROM verortung WHERE plz = :plz LIMIT 1;";
    $result = $this->ExecuteQuery($sql, array("plz"=>$plz));

    var_dump($result);
    echo '<pre>';
    print_r($result);
    echo '</pre>';

    return $result[0]->_id;
}

Output:

array(1) { [0]=> object(stdClass)#32 (13) { ["_id"]=> string(8) "43006637" ["gemeindekennziffer"]=> string(5) "32330" ["gemeindename"]=> string(13) "Theresienfeld" ["ortsname"]=> string(13) "Theresienfeld" ["plz"]=> string(4) "2604" ["bezirk"]=> string(21) "Wiener Neustadt -Land" ["bundesland"]=> string(17) "Niederösterreich" ["lat"]=> string(11) "47.85000000" ["lon"]=> string(11) "16.23333330" ["einwohner_2001"]=> string(4) "2490" ["kfz-kennzeichen"]=> string(2) "WB" ["fläche_km2"]=> string(5) "11.44" ["seehöhe"]=> string(3) "282" } }

Array
(
    [0] => stdClass Object
        (
            [_id] => 43006637
            [gemeindekennziffer] => 32330
            [gemeindename] => Theresienfeld
            [ortsname] => Theresienfeld
            [plz] => 2604
            [bezirk] => Wiener Neustadt -Land
            [bundesland] => Niederösterreich
            [lat] => 47.85000000
            [lon] => 16.23333330
            [einwohner_2001] => 2490
            [kfz-kennzeichen] => WB
            [fläche_km2] => 11.44
            [seehöhe] => 282
        )

)

NULL

Notice: Trying to get property of non-object in /home/www/home/includes/class.DatabaseQuery.php on line 4507

  • 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-17T17:17:43+00:00Added an answer on June 17, 2026 at 5:17 pm

    You’re probably calling this method multiple times. In the first call everything is all right, but in the next one…

    See that NULL? Surely you cannot get a property of NULL.

    If that’s not the case, then line 4507 points to somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, i wrote this code, and it works. But, it only returns one result.
I'm trying to get a single result from my database, just one name. I
I have a variable which I get from database I want to output this
I am querying results from a database, where more than one result should be
I am trying to make one query, to get some statistic data from database.
I've a php function to get some data from mysql database: function get_persons() {
My controller get datas from database model, and sends them to view. In view
How can i get the date from database and load it onto the UIDatePicker?
How to get start date and end dates in a query from database.
Suppose you want to get a record from database which returns a large amount

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.