Welcome Guest, Not a member yet? Register   Sign In
Undefined property: CI_Loader::$db
#1

[eluser]vickel[/eluser]
I'm new to CI and stuck when trying to connect to mySQL database

my code is like suggested in the userguide:

<?php
$this->load->database();
//$this->db->query('SELECT username FROM users');
$query = $this->db->query('SELECT username FROM users');

foreach ($query->result_array() as $row)
{
echo $row['username'];
echo "<br>...<br />";
}
?&gt;

unfortunately I get this error:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$db
Filename: views/dbteste.php
Line Number: 12

if anyone could explain me this, I'd apreciate immensly, thanks
#2

[eluser]thinkigniter[/eluser]
My guess is that your doing this in the view and not the controller.

Try putting this code in your controller and commenting out the line to your view.

Why?
Because your calling the DB class from outside of the parent class. I think.

Cheers
#3

[eluser]vickel[/eluser]
thank you a lot, that was the reason !




Theme © iAndrew 2016 - Forum software by © MyBB