It looks like you're new here. If you want to get involved, click one of these buttons!
7
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: plant
Filename: core/Loader.php(332) : eval()'d code
Line Number: 57
NULL
$where .= "((PlantScientific LIKE '%".$pname."%') OR (PlantCommon LIKE '%".$pname."%'))";
$vars['plants'] = $plnts = fuel_model('plants', array ('select'=>'PlantScientific, PlantCommon, PlantUnique','order'=>'PlantScientific','where'=>$where));
$vars ['plnt_count'] = count ($plnts);
$this->fuel->pages->render('plants/plants', $vars);
<?=$plnt_count?>
<? foreach ($plants as $plant) { ?>
<?=gettype($plant)?>
<? } ?>
The generated code (from show source)
7
<? foreach ($plants as $plant) {; ?>
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: plant
Filename: core/Loader.php(332) : eval()'d code
Line Number: 57
NULL
<? }; ?>
The "NULL" is coming from the gettype since $plant is never set.
FuelCms is obviously changing the code into something that appears to be html (usually gets highlighted like a comment)
Any ideas?
Thanks.
Comments
require_once(FUEL_PATH.'models/base_module_model.php'); class Plants_model extends Base_module_model { function __construct() { parent::__construct('srd_plants'); } #Used in admin to display list for editing function list_items($limit = NULL, $offset = NULL, $col = 'PlantScientific', $order = 'asc') { $this->db->select('id, PlantScientific,PlantCommon', FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; } function form_fields($values = array()) { $fields = parent::form_fields($values); return $fields; } } class Plant_model extends Base_module_record { }
Also if you just use fuel_model('plants') without the additional query parameters, do you have the same problem?
Lastly, does this work?
<?php foreach ($plants as $plant) : ?> <?=gettype($plant)?> <? endforeach; ?>
Your comment sent me back to looking at long and short tags in both fuelcms configuration and php.ini, and that was the answer -- thanks.
I had started with long tags and it did not work -- however, it seems to be working now with
<?php foreach ($plants as $plant) : ?> <?=gettype($plant)?> <?php endforeach; ?>
and I'm guessing, that I also forgot to make the closing tag a long one.The entire range of errors that I've gotten would suggest that there may be an issue with
the fuelcms configuration setting
$config['rewrite_short_tags'] = TRUE;
(short tags are off in my php.ini).<?
tags, just<?=
tagshttps://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/Loader.php