![]() |
Cant load my view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Cant load my view (/showthread.php?tid=40885) |
Cant load my view - El Forum - 04-21-2011 [eluser]lucasvm[/eluser] Hello Im new in CodeIgniter and im trying to create simple website, i want to show my index page but im getting this error: A PHP Error was encountered Severity: Notice Message: Undefined property: Index::$load Filename: controllers/index.php Line Number: 6 Fatal error: Call to a member function view() on a non-object in site\application\controllers\index.php on line 6 My controller index.php has this: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); And in views the html code in index.php Any solution? Cant load my view - El Forum - 04-21-2011 [eluser]danmontgomery[/eluser] You can't name a controller Index. http://ellislab.com/codeigniter/user-guide/general/reserved_names.html Cant load my view - El Forum - 04-21-2011 [eluser]lucasvm[/eluser] Thank you, thats works, but now im trying to show some content from my database but i get undefined variable data on my index, this is my code in funcion index: Code: function index() but if i do echo $data on my index view i get variable undefined, why? Cant load my view - El Forum - 04-21-2011 [eluser]InsiteFX[/eluser] Code: function index() InsiteFX Cant load my view - El Forum - 04-21-2011 [eluser]cahva[/eluser] [quote author="lucasvm" date="1303428949"] but if i do echo $data on my index view i get variable undefined, why?[/quote] When you pass $data to your view, there wont be a variable called $data in your view(unless you have $data['data'] set). From your example you would have $titulo, $contenido and $autor at your disposal. But there is an error in your controller also. You iterate through the result and set the variables with the same name over and over again. You would only have the last $titulo etc. from the result. Just pass the whole result to your view(and btw, you should put the db calls to model): Code: // In controller In view: Code: <table> |