Welcome Guest, Not a member yet? Register   Sign In
Problem with the db->get('') function
#1

[eluser]Unknown[/eluser]
Hello,

I;m a newby in CI, i am doing the blog tutorial but in the db conection step apears a problem in my brower, this is the error

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$db

Filename: controllers/blog.php

Line Number: 13


and this is the code of blog.php

Code:
<?php
class Blog extends Controller{

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

}
    
?>

I have been checking this file and i can not find eny erros , i hope you can help me
#2

[eluser]Dam1an[/eluser]
You need to either manually load the database or autoload it
#3

[eluser]Gordaen[/eluser]
As Dam1an said, you need:

Code:
$this->load->database();
#4

[eluser]Unknown[/eluser]
Thanks it works perfectly, in the tuto were nothing about loading the database class
#5

[eluser]Colin Williams[/eluser]
Which tuto are you talking about? It's the first item on http://ellislab.com/codeigniter/user-gui...mples.html




Theme © iAndrew 2016 - Forum software by © MyBB