views:

16

answers:

3

Hi everyone im new to a PHP framework codeIgniter, I am going over the user guide iv ran in to a problem, I am on the part where you load helper file but for some reason my code just isnt working I keep getting this error:

Fatal error: Call to undefined function anchor() in /home/fresherd/public_html/CI/system/application/views/blogview.php on line 17

now im not 100% sure that it is loading the helper file this could be causing the but I am not sure how to detect the file has been loaded

any advice will help many thanks, Alan

A: 

Make sure that your controlLer, has the parent statment in the construct

function __construct(){
     parent:: ControlLer();
}
Gerardo Jaramillo
A: 

Just load the helper in your controller or put it in the auto load array.

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

I would also change Gerardo's code to this:

function _construct() { parent::__construct(); }

Eric
thanks mate but for some reason it just isn't workingthis is my code what I haveblog.php file :<?phpclass Blog extends Controller{ function _construct() { parent::__construct(); } function index() { $data['todo_list'] = array('Clean House','call mum','do other jobs'); $data['title'] = "My array title!"; $data['heading'] = "My array heading"; $this->load->view('blogview', $data,",true"); $this->load->helper('url'); } function comments() { echo 'Look at this!'; }}?>
blogview.php file<html><head><title><?php echo $title;?></title></head><body> <h1><?php echo $heading;?></h1> <h3>My todo list </h3> <ul> <?php foreach($todo_list as $item):?> <li><?php echo $item;?></li> <?php endforeach;?></ul> <?php echo anchor('blog/comments','Click Here');?></body></html>know in me its something really easy like a spelling error..
sorry if that's hard to read.
A: 

One question, what is the function of making the parent of the class the construct itself?

is just out of curiosity :-)

Gerardo Jaramillo
any idea why its not working still?
iv got it working now via the autoloader.php but still have no idea why the other way wasnt working, thanks tho guys :)
you need to load the helper every time, and by doing it in the autoloader.php you are loading the helper to every file.
ggfan