CodeIgniter Forums
Message: Undefined property: $db - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Message: Undefined property: $db (/showthread.php?tid=68430)



Message: Undefined property: $db - desbest - 07-10-2017

I included this line in my controller.


Code:
$countusername = count($this->db->query("SELECT * FROM users WHERE username = '$_POST[username]'")->result_array()); 


And I get this error.


Quote:Message: Undefined property: Makenew::$db


Why? I configured my database correctly.


RE: Message: Undefined property: $db - Paradinight - 07-10-2017

(07-10-2017, 09:13 AM)desbest Wrote: I included this line in my controller.


Code:
$countusername = count($this->db->query("SELECT * FROM users WHERE username = '$_POST[username]'")->result_array()); 


And I get this error.


Quote:Message: Undefined property: Makenew::$db


Why? I configured my database correctly.

You need to autoload it or load it manually
https://www.codeigniter.com/user_guide/database/connecting.html

and

database request should be in the model