Fatal error: Call to undefined function base_url()

20,073

Solution 1

You need to load the URL helper

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

Solution 2

You need to write

 public function __construct() {
   parent::__construct();
   $this->load->helper('url');
}

In your controller and then use in your view

Share:
20,073
Ashley Stewart
Author by

Ashley Stewart

Updated on August 11, 2020

Comments

  • Ashley Stewart
    Ashley Stewart over 3 years

    This line keeps giving me the aforementioned error:

    <img style="padding:10px; margin:auto; display:block;" <?php echo 'src="' . base_url("assets/images/email/mailheader.jpg") . '"' ?>>
    

    I'm running this on xampp and can't seem to figure it out, any help would be greatly appreciated.

  • Ashley Stewart
    Ashley Stewart about 10 years
    $autoload['helper'] = array('common_functions', 'form', 'url'); is already present in autoload.php
  • cornelb
    cornelb about 10 years
    Can you also include the code I added, at the beginning of the view?
  • Ashley Stewart
    Ashley Stewart about 10 years
    doing so results in Fatal error: Using $this when not in object context
  • gurudeb
    gurudeb about 10 years
    are you using it in a helper function? probably you have not extended the codeigniter controller... Use $CI = get_instance(); For older versions of php, use =& Then, use $CI wherever you would normally use $this