Welcome Guest, Not a member yet? Register   Sign In
Problem after I change the default route
#1

[eluser]Unknown[/eluser]
I can run a vanilla install of CI and get to the welcome screen, but I get an "HTTP 500 error" after I changed the following in application/config/routes.php
Code:
$route['default_controller'] = "welcome";
to
Code:
log_message('debug','loaded ../application/config/routes.php');
$route['default_controller'] = "homepage";


It doesn't even load .../application/controllers/homepage.php
Code:
<?php
log_message('debug','loaded .../application/controllers/homepage.php');
class Homepage extends MY_Controller {
    
    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        // Load required libraries
        $this->load->library('ion_auth');
        $this->load->helper('url');
        
        $page['content'] = 'welcome_message';
        $this->load->view('template', $page);
    }
}
?>

logging is set to 4 and all I get is the following in the log
Code:
DEBUG - 2011-06-12 21:15:18 --> Config Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Hooks Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Utf8 Class Initialized
DEBUG - 2011-06-12 21:15:18 --> UTF-8 Support Enabled
DEBUG - 2011-06-12 21:15:18 --> URI Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Router Class Initialized
DEBUG - 2011-06-12 21:15:18 --> loaded ../application/config/routes.php
DEBUG - 2011-06-12 21:15:18 --> No URI present. Default controller set.
DEBUG - 2011-06-12 21:15:18 --> Output Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Security Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Input Class Initialized
DEBUG - 2011-06-12 21:15:18 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-12 21:15:18 --> Language Class Initialized


I'm running Linux, Ubuntu 10.10
PHP Version 5.3.3-1ubuntu9.5
The localhost runs files in /var/www
phpmyadmin works and I can run other php code
My buddy runs this code just fine, but he is using PHP5.2 and on a Mac
Could it be the php version? If not, than any ideas?
#2

[eluser]osci[/eluser]
Code:
class Homepage extends MY_Controller {    
    function __construct()
    {
        parent::__construct();
        log_message('debug','loaded .../application/controllers/homepage.php');
    }
#3

[eluser]Johnny Freeman[/eluser]
Hey Saxywolf,

the only thing I've noticed in your code that could be a problem is that you are extending MY_Controller instead of CI_Controller, but should not be the cause of a HTTP 500 ERROR. In my experience, .htaccess is usually (part of) the problem so I'd backup and delete the .htaccess and see if that helps.

Another thing I just noticed was that you're using a closing php tag. It's generally a bad idea to use a closing php tag in your controllers, models, libraries, and helpers because you run the risk of allowing whitespace to creep in before the output buffer has been sent to the browser. Let me clarify: It is totally possible to use closing php tags without issue. However, why introduce another point of possible failure, especially when it's not necessary?

Copy and paste this into your homepage controller and let us know what happens:

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

// check if this file was found
log_message('debug','loaded ../application/controllers/homepage.php');

class Homepage extends CI_Controller {
    
    public function __construct()
    {
        parent::__construct();
        
        // check if this controller has been instantiated
        log_message('debug','Homepage class instantiated');
    }
    
    public function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
#4

[eluser]Unknown[/eluser]
[quote author="Johnny Freeman" date="1308016990"]Hey Saxywolf,

the only thing I've noticed in your code that could be a problem is that you are extending MY_Controller instead of CI_Controller, but should not be the cause of a HTTP 500 ERROR. In my experience, .htaccess is usually (part of) the problem so I'd backup and delete the .htaccess and see if that helps.

Another thing I just noticed was that you're using a closing php tag. It's generally a bad idea to use a closing php tag in your controllers, models, libraries, and helpers because you run the risk of allowing whitespace to creep in before the output buffer has been sent to the browser. Let me clarify: It is totally possible to use closing php tags without issue. However, why introduce another point of possible failure, especially when it's not necessary?

Copy and paste this into your homepage controller and let us know what happens:

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

// check if this file was found
log_message('debug','loaded ../application/controllers/homepage.php');

class Homepage extends CI_Controller {
    
    public function __construct()
    {
        parent::__construct();
        
        // check if this controller has been instantiated
        log_message('debug','Homepage class instantiated');
    }
    
    public function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
[/quote]

.../application/core/My_Controller.php
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller
{    
log_message('debug','loaded .../application/core/My_Controller.php');
    function __construct()
    {
        parent::__construct();
    }
}

The only .htaccess file is in the .../application/ folder, but renaming it doesn't do anything.

Simply replacing the Homepage.php code then yielded:
Quote:ERROR - 2011-06-14 23:25:58 --> Severity: Notice --> Undefined property: CI_Loader::$ion_auth .../application/views/welcome_message.php 8
So, I added
Code:
$this->load->library('ion_auth');
$this->load->helper('url');
and I got an execution time message in the log!

But I can't add:
Code:
$this->load->view('template', $page);
as it will yield:
Quote:ERROR - 2011-06-14 23:59:50 --> Severity: Notice --> Undefined variable: page .../application/controllers/homepage.php 21
ERROR - 2011-06-14 23:59:50 --> Severity: Notice --> Undefined variable: content .../application/views/template.php 58

So... is there something wrong with MY_Controller?

The real troubling part is that the code I had is from a buddy whose mac it works on just fine.
#5

[eluser]osci[/eluser]
Code:
$page['content'] = 'welcome message';

should not give an error. It's in home controller right? Not in my_controller.

Second error if no page array is passed no $content will be found for view either.
#6

[eluser]toopay[/eluser]
Check your htaccess stuff. Or if it not exist, creates ones. In the past, while i start my new VPS, with ubuntu installed, i spend 2 hours just to figure it out that it need "?" or change one or two regex rules at that damn configuration file.
#7

[eluser]madiha[/eluser]
Establishes a set of ips allowed to pass validation FRC. Useful for external communication to the special website and other payment procesors.




Theme © iAndrew 2016 - Forum software by © MyBB