CodeIgniter Forums
Error with base_url() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Error with base_url() (/showthread.php?tid=68193)



Error with base_url() - dashing - 06-07-2017

Hi everyone, 

I'm actually trying to put online my website.
In local, everything goes fine, but when i send my files on the server (one.com), this message appear when i go to the site: 

"An uncaught Exception was encountered

Type: Error
Message: Call to undefined method CI_Controller::base_url()
Filename: /customers/f/1/b/onsen.be/httpd.www/application/views/errors/html/error_404.php
Line Number: 9
Backtrace:
File: /customers/f/1/b/onsen.be/httpd.www/index.php
Line: 315
Function: require_once"


And there is my error_404.php file:

"<?php



$CI =& get_instance();

if( ! isset($CI))

{

    $CI = new CI_Controller();

}

$CI->load->helper('url');

echo $CI->base_url();
?>
"
I'm working with Codeigniter 3.0.6

Can someone help me with this ? 
It's relly important for me to fix this as soon as possible.

Thanks for the help ! 



RE: Error with base_url() - greywolf - 06-07-2017

(06-07-2017, 10:45 AM)dashing Wrote: Hi everyone, 

I'm actually trying to put online my website.
In local, everything goes fine, but when i send my files on the server (one.com), this message appear when i go to the site: 

"An uncaught Exception was encountered

Type: Error
Message: Call to undefined method CI_Controller::base_url()
Filename: /customers/f/1/b/onsen.be/httpd.www/application/views/errors/html/error_404.php
Line Number: 9
Backtrace:
File: /customers/f/1/b/onsen.be/httpd.www/index.php
Line: 315
Function: require_once"


And there is my error_404.php file:

"<?php



$CI =& get_instance();

if( ! isset($CI))

{

    $CI = new CI_Controller();

}

$CI->load->helper('url');

echo $CI->base_url();
?>
"
I'm working with Codeigniter 3.0.6

Can someone help me with this ? 
It's relly important for me to fix this as soon as possible.

Thanks for the help ! 

echo base_url();

Helpers don't usually add methods to the CI object.


RE: Error with base_url() - greywolf - 06-07-2017

echo base_url();

Helpers don't add methods to the CI object.


RE: Error with base_url() - dashing - 06-08-2017

(06-07-2017, 11:43 AM)greywolf Wrote: echo base_url();

Helpers don't add methods to the CI object.

Thanks for the help.
But now, nothing appear, only a blank page  Sad

Any idea ?


RE: Error with base_url() - dashing - 06-08-2017

(06-08-2017, 02:42 AM)dashing Wrote:
(06-07-2017, 11:43 AM)greywolf Wrote: echo base_url();

Helpers don't add methods to the CI object.

Thanks for the help.
But it still not working Sad

Now i have a 404 error.

Any idea ?



RE: Error with base_url() - InsiteFX - 06-08-2017

If you need another Controller create a MY_Controller and extend from that.


RE: Error with base_url() - dashing - 06-08-2017

Problem solved.

It was an error with my controller name.
It must start with a capital letter...

All this sh*t for one letter lol

Thanks for those who reply me ;-)