20-min-blog-tutorial - "Call to undefined function anchor() in" |
[eluser]muhax[/eluser]
Hello everyone. I am doing the 20-min-blog tutorial and I am stuck on url helper anchor function. When I load the page with this Code: <?php foreach ($query->result() as $row):?> it breaks at anchor. The html source is Code: <html> I go to php error logs and it sais. PHP Fatal error: Call to undefined function anchor() in C:\Users\****\ZendServerCE\Apache2\htdocs\codeIgniter\Invent\system\application\views\blog_view.php on line 12 Im using ZendServerCE. Anyone know what might be the problem here?
[eluser]Shaun Andrews[/eluser]
Are you loading the URL helper: http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]muhax[/eluser]
[quote author="Shaun Andrews" date="1286996571"]Are you loading the URL helper: http://ellislab.com/codeigniter/user-gui...elper.html[/quote] Yes, my blog.php looks like: <?php class Blog extends Controller{ function index(){ function Blog(){ parent::Controller(); $this->load->helper('url'); $this->load->helper('form'); } $data['title'] = "My Blog Title"; $data['heading'] = "My Blog Heading"; $data['query'] = $this->db->get('entries'); $this->load->view('blog_view', $data); } } ?>
[eluser]Bart Mebane[/eluser]
You need to move your constructor outside of the index method: Code: <?php
[eluser]Shaun Andrews[/eluser]
Your constructor shouldnt be inside your index function. Try this: <?php class Blog extends Controller{ function index(){ $this->load->helper(‘url’); $this->load->helper(‘form’); $data[‘title’] = “My Blog Title”; $data[‘heading’] = “My Blog Heading”; $data[‘query’] = $this->db->get(‘entries’); $this->load->view(‘blog_view’, $data); } } ?> You may want to consider adding the url and form helpers to your autoloader: http://ellislab.com/codeigniter/user-gui...oader.html
[eluser]muhax[/eluser]
[quote author="Shaun Andrews" date="1286997558"]Your constructor shouldnt be inside your index function. Try this: <?php class Blog extends Controller{ function index(){ $this->load->helper(‘url’); $this->load->helper(‘form’); $data[‘title’] = “My Blog Title”; $data[‘heading’] = “My Blog Heading”; $data[‘query’] = $this->db->get(‘entries’); $this->load->view(‘blog_view’, $data); } } ?> You may want to consider adding the url and form helpers to your autoloader: http://ellislab.com/codeigniter/user-gui...oader.html[/quote] Thank you guys, it works now. That video tutorial is misleading, they should review it.
[eluser]Shaun Andrews[/eluser]
Glad we could help. I remember working off of those video tutorials almost a year ago, and then they were outdated. I'm sure by now (and with CI2 looming) they're way out of date. They're a good start. There's some other sites that have more recent video (and text) tutorials. |
Welcome Guest, Not a member yet? Register Sign In |