2

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
  • 161
  • 1
  • 3
  • 12
  • 1
    Have you defined a `base_url()` function? – Nick Coons Feb 17 '14 at 16:21
  • http://stackoverflow.com/questions/6449386/base-url-function-not-working-in-codeigniter – user4035 Feb 17 '14 at 16:21
  • Yes, $autoload['helper'] = array('common_functions', 'form', 'url'); is present in autoload.php and the function works when called from other view files, just not this one for some reason. – Ashley Stewart Feb 17 '14 at 16:34
  • how is this view different than the other views? can you post the code from one where it works? are there different controllers? – cornelb Feb 17 '14 at 18:19

2 Answers2

4

You need to load the URL helper

$this->load->helper('url');
cornelb
  • 6,046
  • 3
  • 19
  • 30
  • 3
    $autoload['helper'] = array('common_functions', 'form', 'url'); is already present in autoload.php – Ashley Stewart Feb 17 '14 at 16:27
  • Can you also include the code I added, at the beginning of the view? – cornelb Feb 17 '14 at 16:34
  • doing so results in Fatal error: Using $this when not in object context – Ashley Stewart Feb 17 '14 at 16:35
  • 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 – gurudeb Feb 17 '14 at 16:37
3

You need to write

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

In your controller and then use in your view