Trying to get property of non-object in
Check the manual for mysql_fetch_object()
. It returns an object, not an array of objects.
I'm guessing you want something like this
$results = mysql_query("SELECT * FROM sidemenu WHERE `menu_id`='".$menu."' ORDER BY `id` ASC LIMIT 1", $con);
$sidemenus = array();
while ($sidemenu = mysql_fetch_object($results)) {
$sidemenus[] = $sidemenu;
}
Might I suggest you have a look at PDO. PDOStatement::fetchAll(PDO::FETCH_OBJ)
does what you assumed mysql_fetch_object()
to do
Trying to get property 'id' of non-object only in my website
First of all, clear the caches with $promotion->id
as using the below command.
php artisan config:cache
php artisan view:clear
php artisan route:clear
If you still get the error then use $promotion->userId
as I have seen in your error the object contains userId
, not an id
.
Laravel 5.8: Trying to get property 'prd_name' of non-object
From your information it looks like $arg['details']
is not coming empty and when fetching relation product
in loop, one of the value of $detail
is coming as null
.
Try debugging for each order, what is the value of $arg['details']
.
Trying to get property 'description' of non-object Laravel 6
Try this
public function show($todoId){
$todos = Todo::where('id', $todoId)->get();
return view('todos.show', compact('todos'));
}
Fix error trying to get property of non-object Laravel
You're getting multiple records if you use get()
method.
using first()
you'll get only one collection.
Remove get()
, and use only first()
method
$name = '';
$sub = DB::table('hours')->join('projects', function($join) use ($projectID,$id){
$join->on('hours.project_id', '=', 'projects.id')
->where('hours.project_id', '=', $projectID)
->where('hours.id', '=', $id);
})->select('nameP')->first();
if(!empty($sub)){
$name=$sub->nameP;
}
PHP error code: Trying to get property of non-object
So that means $wp_query->post
is not an object. I havn't used worpress much but It looks like one of the posts must be returning an empty object.
Try this in order to skip over any empty post:
<?php //Display Page Header
global $wp_query;
if(!empty($wp_query->post)){
$postid = $wp_query->post->ID;
echo page_header( get_post_meta($postid, 'qns_page_header_image', true) );
}
wp_reset_query();
?>
Related Topics
Magento - Quote/Order Product Item Attribute Based on User Input
Is Native PHP Support For Web Sockets Available
Best Way to Manage Long-running PHP Script
Insert String At Specified Position
Enabling Error Display in PHP Via Htaccess Only
Remove Control Characters from PHP String
Fpdf Error: Some Data Has Already Been Output, Can't Send Pdf
Trying to Get Property of Non-object In
How to Login in With Curl and Ssl and Cookies
What Does "1" Mean At the End of a PHP Print_R Statement
Redefine Built in PHP Functions
Reference - Composer Error "Your PHP Version Does Not Satisfy Requirements" After Upgrading PHP
How to Combine Two Arrays Together
PHP: Warning: Sort() Expects Parameter 1 to Be Array, Resource Given