Problem with view db query |
[eluser]finord[/eluser]
Hello, first sorry for my english, i dont speak very good I try to load a mysql, i dont know why dont work this script. I check the forum and documents but dont know why dont work. Here is the code: Controller: Code: <? Model: Code: class newstransit extends Model And View: Code: <? This is the error: Quote: A PHP Error was encountered If anyone can help me, thanks.
[eluser]Sean Murphy[/eluser]
[quote author="finord" date="1202583242"] Code: $data['query'] = $this->newstransit->allview(); When you pass an array to a view, indexes from that array are imported into the current symbol table. http://ellislab.com/codeigniter/user-gui...views.html http://us2.php.net/manual/en/function.extract.php Your view, instead of being: [quote author="finord" date="1202583242"] Code: foreach ($data as $row) { Should be: Code: foreach ($query->result() as $row) { And the allview() method in your model should return just $query, not $query->result()
[eluser]Edemilson Lima[/eluser]
Quote:class noticias extends Controller Class names must start with an uppercase: Code: class Noticias extends Controller Also, if you use a constructor and want it to work with PHP4, the function name must be the same of the class and start with an uppercase too: Code: function Noticias() { http://ellislab.com/codeigniter/user-gui...llers.html
[eluser]finord[/eluser]
[quote author="Edemilson Lima" date="1202678492"] Quote:class noticias extends Controller Class names must start with an uppercase: Code: class Noticias extends Controller Also, if you use a constructor and want it to work with PHP4, the function name must be the same of the class and start with an uppercase too: Code: function Noticias() { http://ellislab.com/codeigniter/user-gui...llers.html[/quote] Ahh ok thanks, im a newbie Programming with framework ^^ |
Welcome Guest, Not a member yet? Register Sign In |