Korferer Posted January 2, 2015 Share Posted January 2, 2015 Hi, This code works (and correctly shows just one result in my view); $people = DB::table('people')->where('id', '=', $person_id)->get(); But this one doesn't; $people = DB::table('people')->where('id', $person_id)->first(); And produces the error; Trying to get property of non-object (View: /media/sf_sandbox/health/app/views/agreement/display.blade.php) The `people` table just has a few fields of information on the individual with a primary key called `id`. I followed the Laravel guide on select statements. I don't understand what the error is trying to tell me and I don't get why that second statement is wrong. What's so wrong about it? I just want to understand Laravel/Objects better.... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/293604-help-me-understand-the-non-object-error-message/ Share on other sites More sharing options...
kicken Posted January 3, 2015 Share Posted January 3, 2015 My guess would be that your condition in the second query doesn't match anything (no row has id=$person_id) so the first method returns false. Verify that $person_id contains a valid ID and matches a row in your database. Quote Link to comment https://forums.phpfreaks.com/topic/293604-help-me-understand-the-non-object-error-message/#findComment-1501564 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.