"Undefined property" Error when loading a model |
[eluser]yNaxon[/eluser]
Hello, i'm trying to load a model, but when i'm using it I get an error: Quote:A PHP Error was encountered The Controller (games.php): Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); The model (game.php): Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I have tried lowercase, uppercase, nothing helps.
[eluser]Mirge[/eluser]
Fresh CI install... I copied your controller & model.. worked fine. Output: hello 1 URL: http://localhost/games/cat/1/
[eluser]yNaxon[/eluser]
[quote author="Mirge" date="1313181605"]Fresh CI install... I copied your controller & model.. worked fine. Output: hello 1 URL: http://localhost/games/cat/1/[/quote] Thanks for answering ![]() I'll start over and find the problem. thanks again ![]()
[eluser]Mirge[/eluser]
If you're developing locally & uploading to a remote server (ie: Linux server), make sure your newlines are UNIX newlines & not Windows. Other than that... I'm not sure, it works here ![]() Also make sure that your Game model filename is actually game.php (all lowercase).
[eluser]pickupman[/eluser]
Try using lowercase syntax when loading classes. Code: $this->load->model('Game');
[eluser]Aken[/eluser]
Remember to include the constructor in your model. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Mirge[/eluser]
The parent constructor is called implicitly if the subclass does not define a constructor. You'd only need to explicitly call a parent constructor in the event your child class defines a constructor.
[eluser]Aken[/eluser]
True. I think it's good practice regardless, but you're right it's not necessary in this case. |
Welcome Guest, Not a member yet? Register Sign In |