Welcome Guest, Not a member yet? Register   Sign In
Multiple controllers in MY_Controller problem on hosted server
#1

[eluser]RogerMore[/eluser]
Ok people,

I have a problem I can't get solved and I'm out of idea's.

On the net I found an implementation to use MY_Controller for multiple controllers.
I used this for my project to make a Base controller which extends from controller, and a Front and Admin controller which extend form the Base controller.

So far so good. Worked like a charm... but when I moved my project from my local installation (XAMPP) to a hosted server the problems began.

At first I got a white page, and firebug gave me an '500 Internal server error'.

After checking my config etc. I checked the serverlogs which give me the following message:
- PHP Fatal error: Class 'Public_Controller' not found in /home/httpd/.../application/controllers/SomeForm.php on line 3

Running my code locally was never a problem. Below I will add simplified code of the begin the controller code and also the MY_Controller which doesn't seem to work anymore. I almost forgot to mention that I'm running CI version 1.7.3

If anyone can help me how fix this, I would be most gratefull..

Thanks,

Roger

My controller:
Code:
<?php

class SomeForm extends Public_Controller {

    function SomeForm()
    {
        parent::Public_Controller();
        
        $this->load->library('lib');
        $this->load->model('some_model');        

    }
    
...

My MY_Controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Base_Controller extends Controller {
    function Base_Controller() {  
                
        parent::Controller();
        
            // begin of fireignition stuff
            // ..
            // end of fireignition stuff
        
    }
}

class Admin_Controller extends Base_Controller {
    function Admin_Controller() {  
        
        parent::Controller();

        // for future use
        
    }
}

class Public_Controller extends Base_Controller {    
    public function Public_Controller() {  
        
        parent::Controller();
        
        define('STUFF', 'defining some stuff');
                
        $this->lang->load('language', language_code);
        
        //valide and define more stuff    
        $this->_validate();        
        

    }
    
    
    function _validate() {
        // do validation
        $validateThis = $this->uri->segment(3);

        if (!$validateThis) {
            die('an error!');
        } else { // if there's something to validate..
                    
            // do some db stuff
            
            // nog record found, die with an error
            if ($query->num_rows() == 0) {
                die("another error");
            } else {
                // else get row with data
                $omgArr = $query->row_array();                    
                        
                // and define some more stuff
                define('SOMEMORESTUFF', $omgArr['stuff']);
                
            }
            
        }
            
    }    
    
}

?>
#2

[eluser]InsiteFX[/eluser]
Did you change your MY_ prefix to Base_ in application/config/config.php

Your using Base_Controller but the CI default is MY_Controller unless you change the prefix!

Also you may need to filenames to all lowercase filenames!

InsiteFX
#3

[eluser]RogerMore[/eluser]
[quote author="InsiteFX" date="1301933505"]Did you change your MY_ prefix to Base_ in application/config/config.php

Your using Base_Controller but the CI default is MY_Controller unless you change the prefix!

Also you may need to filenames to all lowercase filenames!

InsiteFX[/quote]

Hi InsiteFX,

Thanks for your post.

I already tried to change the CI default in config.sys, but that doesn't give other results. On top of that, it won't explain to me why it works perfectly on local installation.

The last part about lowercase filenames I didn't understand. I have no idea what you mean, sorry Sad

Roger
#4

[eluser]SPeed_FANat1c[/eluser]
Quote:The last part about lowercase filenames I didn’t understand.

he probably means that filenames must be 'filename.php', not the 'Filename.php'
#5

[eluser]RogerMore[/eluser]
[quote author="SPeed_FANat1c" date="1301939239"]
Quote:The last part about lowercase filenames I didn’t understand.

he probably means that filenames must be 'filename.php, not the 'Filename.php[/quote]

Ok, thanks.

Just to be clear.. My controllers, models and views are lowercase off-course.
My MY_controller starts with uppercase letters, as stated in the application/config/config.php.

Roger
#6

[eluser]InsiteFX[/eluser]
Some servers will not load the files if the filename contains any uppercase charactes!

Example:
File.php - will fail because the server is case sensitive!
file.php - will work!

You may need to rename all your files to lowercase file.php

It would be nice if CodeIgniter used all lowercase filenames would solve these problems

That is my guess of what is happening!

Also an .htaccess file can cause problems like this.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB