Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8415769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:32:35+00:00 2026-06-10T01:32:35+00:00

I have this error controller in my Codeigniter 2.1.0 application: <?php class Error extends

  • 0

I have this error controller in my Codeigniter 2.1.0 application:

<?php

class Error extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        set_status_header(404);
        $data->menuItems = Main::_menu();
        $data->title = "404 error !";
        $data->pageview = 'templates/404';
        $this->load->view('templates/main', $data);
    }

    public function facebook()
    {

        set_status_header(404);            
        $data->menuItems = Main::_menu();
        $data->title = "Facebook error !";
        $data->pageview = "templates/facebook_error";
        $this->load->view('templates/main', $data);
    }
}
?>

The Maincontroller _menu:

<?php
class Main extends CI_Controller
{
    // ...  a lot of methods here ...
    public static function _menu()
    {
            static $menuItems = array( //just a simple array
                                     );
    }
}
?>

facebook() method is totally the same as the index(), however index works fine, facebook() throw this message:

Fatal error: Class 'Main' not found in /var/www/MYApplicationName/application/controllers/error.php on line 22

How the earth is that possible ? How can I reach Main::_menu() from facebook() method ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:32:36+00:00Added an answer on June 10, 2026 at 1:32 am

    Based on @TheShiftExchange’s answer, I was able to track down that a route setting caused this behaviour. My config/routes.php looks like this:

    $route['404_override'] = 'error/index';
    $route['(:any)'] = "main/$1";
    

    So, when I made a request to www.example.com/nonexistent-url this get served by the main controller, then CI noticed that there is no method like this so it ran error/index too, but the main controller was already loaded by then.

    The other method facebook was redirected from an existing method of main only, for example gallery, this way it is like if I went to the url www.example.com/error/facebook, so the main controller is not loaded, because only error/facebook is requested. If I call www.example.com/error/index it works the same, because in this case the main controller is not loaded, only the error.

    (The bounty goes to @TheShiftExchange, because his answer was the most accurate and provided me the best information to able track down the problem. Thanks !
    One of my redirect was never reached, which I tought was calling the error/index page.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into this problem in my Codeigniter app: A PHP Error was
I have a codeigniter application.This is my code in view page. function click_next(){ var
I have this error NOTICE: UNDEFINED VARIABLE: LOGO IN C:\WAMP\WWW\SITE\TOOLS\SMARTY\SYSPLUGINS\SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL
i have built application using codeigniter, my controller name is userReg , in controller
I have an error_codes.php file located in application/libraries I have it autoloaded when CodeIgniter
I'm trying to use PHP ActiveRecord in Codeigniter. I have a model like this:
For Security reasons as mentioned here http://codeigniter.com/user_guide/installation/index.html I have placed the system and application
I have class MY_Controller extends CI_Controller and common logic for big profile section, so
I've recently downloaded CodeIgniter and install it in XAMPP htdoc -> codeigniter(application,system,user guide,index.php,license.txt) I've
I have this error when trying to generate the meta model with JOOQ: org.jooq.exception.DataAccessException:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.