Trying to get property 'name' of non-object

Hi guys
Can anyone please tell me why i’m getting this error. This page working properly before this.

Error on this line (view.php)

indent: <td class="text-center">
			<?php echo $project->aircraftType->name;?>

All my view page is not working today…anyone please help me…
Thank you in advance…

@fatinbahseis some of the $project must not have aircraftType. Make sure, all the $project have proper aircraftType. or you can check while displaying the data. like

<td class=“text-center”>
<?php if ($project->aircraftType) { ?>
<?php echo $project->aircraftType->name;?>
<?php } ?>

Thank you…its work for a moment and then error again…

This error:
syntax error, unexpected ‘endforeach’ (T_ENDFOREACH)

indent: <?php $i=1;
		foreach ($model as $project):?>
            <td class="text-center">
		       <?php if ($project->aircraftType) {?>
		       <?php echo $project->aircraftType->name;?>

Its okayy @imanilchaudhari…i get what i want…i just delete all the dummy data in my database…and enter new data…it work…thank you for syour sharing…i will use it for future improvement…

1 Like