Welcome Guest, Not a member yet? Register   Sign In
Model code loading into browser
#1

[eluser]sday[/eluser]
When I load my model, the model code shows up in the browser as if it's just loading a text file to display to the user!? What is going on. CI v2.1.2

Code:
class Admin extends CI_Controller {
   function migrate_user()
    {
        $this->load->model('admin_model');
    }
}

this is what shows up in the browser when I browse to: http://myserver.com/index.php/admin/migrate_user

Code:
class Admin_model3 extends CI_Model { function __construct() { parent::_contstruct(); } function migrate_user() { return "done 3b"; } }

The answer is probably so obvious, but with the bruises on my head from repeated smacking, I can no longer think. Smile

Thanks for any help
-Steve
#2

[eluser]sday[/eluser]
Just tried it with CI 2.1.3 same results. I must be doing something wrong. It's such a simple example and I can't figure it out.
#3

[eluser]Aken[/eluser]
Well, according to the output being shown in the browser, there are a lot of things wrong. I'd start by checking if the document actually starts with the <?php opening tag and go from there.
#4

[eluser]sday[/eluser]
I started over with a basic example with new files to make sure I didn't have some strange characters in there. Still the same thing and yes it does have the <?php

Here is the exact code:
controllers/test.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Test extends CI_Controller {
public function index()
{
  $this->load->model('test_model');
  echo $this->test_model->migrate_user();
}
}

models/test_model.php
Code:
class Test_model extends CI_Model {
function migrate_user()
{
  return "We should see this";
}
}

browser output: (all bunched together on one line in the browser, tried Chrome,Firefox,Safari in case it was something with the browser? )
Code:
class Test_model extends CI_Model { function migrate_user() { return "We should see this"; } }
#5

[eluser]sday[/eluser]
oh geeze. Like you said, <?php

my model isn't wrapped in

<?php
?>

I need to "step away from the computer" lol

thanks
#6

[eluser]Aken[/eluser]
You can skip the closing ?> PHP tag in files that are strictly PHP (like controllers and models).
#7

[eluser]sday[/eluser]
thanks. I'll probably never have a handle on all the little things like that. I switch between too many languages, I'm bound to get it wrong again next time. Smile

thanks again




Theme © iAndrew 2016 - Forum software by © MyBB