Why do I get "Call to a member function on null ..." on a variable that my class initializes in its constructor? [closed]
I have done all sorts of things to understand what is actually wrong with the code, but I just couldn't figure out what was causing this error. Below is class called Topic: class Topic { // Init DB variables private $db; /* * Constructor */ public function __contruct() { $this->db = new Database(); } /* * Get All Topics */ public function getAllTopics() { $this->db->query("SELECT topics.*, users.username, users.avatar, categories.name FROM topics INNER JOIN users ON topics.user_id = users.id INNER JOIN categories ON topics.category_id = categories.id ORDER BY create_date DESC"); // Assign the
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.