contents of php file shows in browser window |
[eluser]entropy[/eluser]
when I run the command: '$this->load->model('Database_construct');' in the main controller (testing), while the file 'database_construct.php' in the 'application/models' directory, and the syntax of this file correct as far as I can see (twenty-times checked), it doesn't run but shows the contents of the file 'database_construct.php' in the browser window. What is wrong here? (I don't include the contents of 'database_construct.php' here for privacy reasons)
[eluser]TWP Marketing[/eluser]
Can you post your test controller code in which the model is used? I would like to see how you are loading the views in the controller and the name of the view files.
[eluser]entropy[/eluser]
Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I include a censured version of the model: Code: class Database_construct extends CI_Model { This is the very first test of the very first time I use CI.
[eluser]GlenW[/eluser]
It sounds like PHP isn't running on your testing environment. What's your setup?
[eluser]entropy[/eluser]
[quote author="GlenW" date="1350415497"]It sounds like PHP isn't running on your testing environment. What's your setup?[/quote] I use wampp locally succesfully with other sites for developing.
[eluser]TWP Marketing[/eluser]
May not be related, but you are loading three views in your controller: Code: ... If you have sub-views (top,middle,end) then you need a template to display them: a template view file (/application/views/somename.php) Code: <html> [EDIT] See the User Guide: http://ellislab.com/codeigniter/user-gui...oader.html for the format of the load->view() method Code: ...
[eluser]entropy[/eluser]
I found the answer: First of all, all php files must begin with: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Then I also have to connect to the database. Then it works Thanks for the interest in this topic of mine
[eluser]GlenW[/eluser]
[quote author="TWP Marketing" date="1350416902"] May not be related, but you are loading three views in your controller: [/quote] Probably because the tutorial does the same: Code: public function view($page = 'home') Also, I do the same in my controllers and it works fine.
[eluser]TWP Marketing[/eluser]
Ahha, I've been using the template approach for so long I forgot about the other option. Thanks. |
Welcome Guest, Not a member yet? Register Sign In |