Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

php notice errors

edited March 2014 in Modules
I am trying to figure out why i am getting php notice errors for line 12 and 14 - these show up above my data which gets printed right after the notices are displayed.
//////////////////////////////////
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/projects.php
Line Number: 12

Line #12 & #14 are:
//12 <h5><?php echo $projects->heading; ?></h5> //14 <?php echo $projects->description; ?>

views/projects.php

$list_where = array('featured' => 'yes'); $model = 'projects_model'; $projects = fuel_model($model, array('find' => 'all','limit' => 10 ,'where' => $list_where)); ?> <?php if (!empty($projects)) : ?> <?php foreach($projects as $project) : ?> <h5><?php echo $projects->heading; ?></h5> <p> <?php echo $projects->description; ?> </p> <?php endforeach; ?> <?php endif; ?>

Comments

  • edited 1:45AM
    You need to use $project and not $projects with the "s". $projects is an array of $project records.
  • edited 1:45AM
    dohhh... lolz.. that was stupid mistake.. thanks
Sign In or Register to comment.