Welcome Guest, Not a member yet? Register   Sign In
Call to undefined function anchor( ) when stepping through the tutorial.
#1

[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?
#2

[eluser][email protected][/eluser]
you might need to load the URL helper..
#3

[eluser]Chris (from L.C.)[/eluser]
[quote author="[email protected]" 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
#4

[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.
#5

[eluser][email protected][/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...




Theme © iAndrew 2016 - Forum software by © MyBB