CodeIgniter Forums
Error with Video Tutorial - Blog - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Error with Video Tutorial - Blog (/showthread.php?tid=3346)



Error with Video Tutorial - Blog - El Forum - 09-25-2007

[eluser]rufus99[/eluser]
I have this controller code:

Code:
<?php

class Blog extends Controller
{

    function Blog()
    {
        parent::Controller();
    
    }
    
    
    function index()
    {
        print_r($this);
        $data['query']  = $this->db->get('entries');
        
        $this->load->view('blog_view', $data);
    
    }
}

?>

and I get this error:
---------------------

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$db

Filename: controllers/blog.php

Line Number: 16

Fatal error: Call to a member function get() on a non-object in C:\Inetpub\wwwroot\ignite\system\application\controllers\blog.php on line 16


Not too sure what I am doing wrong. Could I get some help?
Thanks.


Error with Video Tutorial - Blog - El Forum - 09-25-2007

[eluser]Michael Wales[/eluser]
Make sure you are autoloading the database libary in config.php


Error with Video Tutorial - Blog - El Forum - 09-25-2007

[eluser]rufus99[/eluser]
I have this in my autoload.php :

Code:
$autoload['core'] = array('database');

Do I need something in the config.php also?

Thanks.


Error with Video Tutorial - Blog - El Forum - 09-25-2007

[eluser]Michael Wales[/eluser]
The documentation is a bit messed up (or maybe this changed since the video tutorial was produced), it should be:
Code:
$autoload['library'] = array('database');

I think it's library, maybe libraries... not looking at the code right now... the comments within the autoload.php file show you exactly where to place it though.


Error with Video Tutorial - Blog - El Forum - 09-25-2007

[eluser]rufus99[/eluser]
Awww,

Thanks man. It is working now.

So far CI is rockin!


Error with Video Tutorial - Blog - El Forum - 10-10-2007

[eluser]bgougent[/eluser]
Maybe the video seems to need an update.

Also error when putting CI in subfolder - scaffoldig is not working.