Welcome Guest, Not a member yet? Register   Sign In
Undefined property: stdClass::$ID
#1

[eluser]Unknown[/eluser]
Hi, I'm new to codeigniter and PHP for that matter.
I've installed everthing I need and things are mostly working.
My config is as follows

PHP 5.2.14
Windows
IIS

I've tried following the Tutorial Blog videos but can't complete the second tutorial beyond the Scaffolding part.
When using scaffolding I am able to add records but they will not display. The problem seems to happen in the scaffolding view.php

line 17 results in "Undefined property: stdClass::$ID" error.
Here's the line from codeigniter scaffolding view.php

<td>&lt;?php echo form_prep($row->$field);?&gt;</td>

I have tried to debug this. The line executes in a loop. The first iteration $field = "ID"

Indeed, if I replace $field with "ID" i.e.

<td>&lt;?php echo form_prep($row->ID);?&gt;</td>

it works just fine.

What is the problem?
regards
Peter
#2

[eluser]Unknown[/eluser]
OK - found the problem. I'm using a Firebird database and it seems the field names were being returned with trailing blanks for some reason. Here's how I fixed it in the scaffolding\view.php

&lt;?php foreach($fields as $field): ; ?&gt;
&lt;?php $MyField = trim($field);?&gt;
<td>&lt;?php echo form_prep($row->$MyField);?&gt;</td>

This works.
regards
Peter




Theme © iAndrew 2016 - Forum software by © MyBB