CodeIgniter Forums
Blog Tutorial -noob - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Blog Tutorial -noob (/showthread.php?tid=5005)



Blog Tutorial -noob - El Forum - 12-30-2007

[eluser]Tetek[/eluser]
hi everyone
I'm new and I have just started to learning Code Igniter. I have a problem with the blog tutorial. I have all the same as on the film but all time I have this on my screen:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$db

Filename: controllers/blog.php

Line Number: 15

Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\system\application\controllers\blog.php on line 15

Code from 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');
        
        $this->load->view('blogview', $data);
    }
}

?>

From blogview
Code:
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1>&lt;?=$heading?&gt;</h1>


&lt;?php foreach($query->result() as $row):?&gt;

<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>

<hr>

&lt;?php endforeach;?&gt;

&lt;/body&gt;
&lt;/html&gt;

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

database
Code:
$active_group = "default";

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "blog";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

And I don't know where is a mistake ;(
Please help!
greetz Tetek


Blog Tutorial -noob - El Forum - 12-30-2007

[eluser]Craig A Rodway[/eluser]
In autoload.php, it should be:

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



Blog Tutorial -noob - El Forum - 12-30-2007

[eluser]Tetek[/eluser]
It works!, thanks a lot ;] And sorry for so stupid mistake, I'm beginner. greetz