![]() |
Help! Call to a member function on a non-object in .... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Help! Call to a member function on a non-object in .... (/showthread.php?tid=4196) |
Help! Call to a member function on a non-object in .... - El Forum - 11-12-2007 [eluser]otherjohn[/eluser] Ok,so I am getting this error "Fatal error: Call to a member function on a non-object in /home/domain/public_html/****/application/views/areacode_view.php on line 49" My controller looks like this: Code: class PhoneNumbers extends Controller { My Model is Code: class AreaCode_model extends Model { Code: <?php foreach($query->result() as $row): ?> OK so I don't understand why I am getting this error? Can anyone see whats going on here? NOTES: uri->segment(1) would return area-code-555 so I extract the 555 out of it. thanks Help! Call to a member function on a non-object in .... - El Forum - 11-12-2007 [eluser]Rick Jolly[/eluser] Instead of calling a private method in your controller from your view: 1) create a helper with that function 2) load the helper in the controller 3) call the helper function in your view. Helpers are meant for this sort of thing - formatting data in the view. Also, it allows you to reuse that formatting code in various controllers/views. Help! Call to a member function on a non-object in .... - El Forum - 11-12-2007 [eluser]otherjohn[/eluser] thanks, I will look into helpers. I found the problem. In my view page i had $query->result() and there was already a "result()" in my model. I removed that and it worked! thanks ps, I am loving this framework! its so easy Help! Call to a member function on a non-object in .... - El Forum - 05-28-2008 [eluser]RaZoR LeGaCy[/eluser] I just upgraded my codeignitor from 1.6.1 to 1.6.2 and I am now recieving this message everywhere |