Welcome Guest, Not a member yet? Register   Sign In
newbie needs help
#1

[eluser]coding[/eluser]
hi all . this is my first post. I'm a student and want to learn php and codeigniter. i downloaded the tutorial videos i'm trying to build a weblog watching the tutorial video but i'm getting an error. may be simple but can't figure out so please help me figure it out.

first of all here is the error..........
------------------------------------------------------------------------------
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$db

Filename: controllers/home.php

Line Number: 12

Fatal error: Call to a member function get() on a non-object in D:\Program Files\xampp\htdocs\CI\system\application\controllers\home.php on line 12
-----------------------------------------------------------------------------

now here is home.php
-----------------------------------------------------------------------------
<?php

class Home extends Controller {

function Home()
{
parent::Controller();
}

function index()
{
$data['query']= $this->db->get('movies');
$this->load->view('home_page',$data);


}
}

?>

---------------------------------------------------------------------------------

and home_view.php

----------------------------------------------------------------------------------
<html>
<head>
<title>

</title>
</head>
<body>
ok this is the page.
<?php foreach($query->result() as row): ?>

<?php $row->id ?>

<php? endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;
------------------------------------------------------------------------------------

i've configured database correctly. config->database file.

please help me learn this framework thing.
#2

[eluser]Twisted1919[/eluser]
Load the database driver first Wink
$this->load->database() ;

In your controller , you can do it right under parent::Controller() , or you can autoload it from autoload.php located in config folder and be sure to fill out the data from database.php also located in your config folder .


Welcome to CI btw Smile
#3

[eluser]coding[/eluser]
Thanks 'twisted1919' it worked. i think i've a long road to go.this is the fastest reply I've ever received on any forum. CI rocks.
#4

[eluser]Twisted1919[/eluser]
You've seen nothing so far Wink
Just follow that user guide and you will see that everything will work very smooth .
Happy dev with CI Smile




Theme © iAndrew 2016 - Forum software by © MyBB