Models causing blank pages |
[eluser]phused[/eluser]
I'm having an issue with my models, each time I load a model on one of my controllers the page appears blank. For example, this is one of my controllers: Code: <?php My tickets model has the following code, fairly simple and easy: Code: <?php When I try to access /tickets page, it appears blank. However, once I remove the $this->load->model('Tickets_model'); it loads perfectly fine. I have tried to uncomment certain sections of the model to see if it was a specific part of it, but it all combinations lead to the Tickets index() page rendering blank. Any ideas?
[eluser]Pascal Kriete[/eluser]
Hey Xirgo, Let's start with the syntax errors. I see two right now: 1) The database loading call should be in a method, in this case the constructor is probably the best choice. Classes are not processed top-down, and can't contain any logic outside of class methods. 2) Your second method declaration needs a pair of parentheses to be valid. Blank pages usually indicate that the script has one or more syntax errors and the PHP interpreter can't parse it. A lot of setups don't show parse errors by default, but there is a PHP directive called 'display_errors' that will turned them on. Errors sneak in quite a lot, so it's nice to have a development setup that will show them. Production should, of course, fail silently (or not at all ![]() Let us know how that goes. Welcome to CodeIgniter.
[eluser]phused[/eluser]
Thanks for the information, it was helpful. I have updated my code and also edited my PHP configuration although I seem to be getting another error which I'm sure isn't! My code is looking like this now: Code: <?php This is the error I'm getting now: Quote:Parse error: syntax error, unexpected '{' in /var/www/html/CodeIgniter/system/application/models/tickets_model.php on line 3 What am I doing wrong, any ideas? Thanks in advance ![]()
[eluser]Pascal Kriete[/eluser]
Hmm... I copy-pasted your post, loaded it, and it worked fine ![]()
[eluser]phused[/eluser]
Just to confirm, the model's file name is tickets_model.php and the controller file name is tickets.php, right?
[eluser]Pascal Kriete[/eluser]
The controller (file) name is irrelevant in this case, but the model has to be called tickets_model.php . |
Welcome Guest, Not a member yet? Register Sign In |