Welcome Guest, Not a member yet? Register   Sign In
Error with Video Tutorial - Blog
#1

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

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

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

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

[eluser]rufus99[/eluser]
Awww,

Thanks man. It is working now.

So far CI is rockin!
#6

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

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




Theme © iAndrew 2016 - Forum software by © MyBB