• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] mystical error - Class 'MY_Controller' not found

#1
[eluser]SPeed_FANat1c[/eluser]
Hi,

I have an extended controller - MY_Controller.php
Code:
<?php
class MY_Controller extends CI_Controller{
  
  var $data;

  public function __construct(){
    parent::__construct();
    
    //default data
    $this->data['title'] = 'Plotai.eu - pradžia';
    $this->data['meta'] = array(
                0 => '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',
            );
    $this->data['javascript'] = '';
    $this->data['virsutinis_meniu'] = $this->get_top_menu();
    $this->data['cities_meniu'] = $this->get_cities_menu();
    $this->data['current_menu'] = 99;    //99 reiskia joks meniu nera aktyvus

    
    //sidearui
    $this->data['banners'] = $this->get_banners();
    
    /*
    //footeriui, jie noresim dinaminiu duomenu
    $this->data['footer'] = $this->Views_model->data_for_footer();
    */        
  }
  
  /*
   * paduodam main sekcijos view faila, taip pat kaip ir this load view kai paduodume
   */
  function display($main_view){
  
       $this->load->vars($this->data);
      
     $this->load->view('header_view');
     $this->load->view('cities_view');
     $this->load->view($main_view);
     $this->load->view('sidebar_view');
     $this->load->view('footer_view');
  }
  
    private function get_top_menu()        
    {
        $this->db->order_by('Eile','asc');
        $query = $this->db->get('virsutinis_meniu');
        return $query->result_array();
    }
    
    private function get_links()
    {
        $query = $this->db->order_by('vieta','asc')->get('nuorodos');
        return $query->result();
    }
    
    function get_banners()
    {
        $query = $this->db->order_by('queue','asc')->get('reklama');
        return $query->result();
    }
}

And made a test.php controller:

Code:
<?php  

class Test extends MY_Controller {

    function __construct();
    {
        parent::__construct();
    }
    
    function index()
    {
        
        
    }
}

I go to address http://localhost/plotai5/test (the CI2 appilication is in folder plotai5) and get error

Fatal error: Class 'MY_Controller' not found in E:\Program Files\xampp\htdocs\plotai5\application\controllers\welcome.php on line 4

Why it even looks at welcome.php if I want test.php?

#2
[eluser]Phil Sturgeon[/eluser]
Firstly if the URI is not responding correctly change the uri_protocol, that fixes most issues.

Secondly, if your MY_Controller cannot be found you are either not loading it properly (via an __autoload() or manually using include()) or it is in the wrong place. In CI 2.0 MY_Controller should be in application/core.

#3
[eluser]SPeed_FANat1c[/eluser]
Thanks Smile changed uri_protocol to 'REQUEST_URI' and moved MY_Controller from application/libraries to apllication/core and it works perfectly now Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.