CodeIgniter Forums
Call to undefined function anchor( ) when stepping through the tutorial. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Call to undefined function anchor( ) when stepping through the tutorial. (/showthread.php?tid=2220)



Call to undefined function anchor( ) when stepping through the tutorial. - El Forum - 07-23-2007

[eluser]Chris (from L.C.)[/eluser]
I'm steeping through the video tutorial, and I'm stuck on the adding the comment form helper. I've correctly added the helpers in blog.php, and the anchor call, but I'm getting this error:

Call to undefined function anchor() in /home/quickgig/public_html/system/application/views/blog_view.php on line 17

I've left it up at http://www.quickgig.com/blog, along with the
Code:
<?php phpinfo(); ?>
tag incase there is something there helpful.

Here's the blog.php code:

Code:
<?php
class Blog extends Controller {

function blog()
{
  parent::Controller();
  
  $this->load->helper('url');
  $this->load->helper('form');
}

function index()
{
  $data['title'] = "Blog Title";
  $data['heading'] = "Blog Heading";
  $data['query'] = $this->db->get('entries');
  
  $this->load->view('blog_view', $data);
}
}
?>

and the blog_view.php code:

Code:
<html>
<head>
<title><?=$title; ?></title>
</head>

<body>
<h1>&lt;?=$heading; ?&gt;</h1>

&lt;?php phpinfo(); ?&gt;

&lt;?php foreach($query->result() as $row): ?&gt;



<h3>&lt;?=$row->title?&gt;</h3>
<br>
<p>&lt;?=$row->body?&gt;</p>

<p>&lt;?=anchor('blog/comments', 'Comments');?&gt;</p>

<hr>
&lt;?php endforeach; ?&gt;



&lt;/body&gt;
&lt;/html&gt;


Ideas?


Call to undefined function anchor( ) when stepping through the tutorial. - El Forum - 07-23-2007

[eluser]Imkow@CN[/eluser]
you might need to load the URL helper..


Call to undefined function anchor( ) when stepping through the tutorial. - El Forum - 07-23-2007

[eluser]Chris (from L.C.)[/eluser]
[quote author="Imkow@CN" date="1185252720"]you might need to load the URL helper..[/quote]

Isn't that what this line

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

is?

It is planted in the blog.php


Call to undefined function anchor( ) when stepping through the tutorial. - El Forum - 07-23-2007

[eluser]Chris (from L.C.)[/eluser]
Ok,...I've found the problem.

lmkow, you're right. My local version was not updating the rmote version of the file, even though it showed me it was. Guess that's what I get for using Dreamweaver to do coding.


Call to undefined function anchor( ) when stepping through the tutorial. - El Forum - 07-24-2007

[eluser]Imkow@CN[/eluser]
hey..
hope you have solved your problem by now. Big Grin
But i found something in your code

Code:
class Blog extends Controller {

function blog()....
The name of constructor method of the Blog class is in lowercase, which is different than the one you put in class declaration. So the constructor might never run each time the class initiated, and the url helper also are not loaded in this case...