I am trying to write a simple program that queries sql to the database using object orientated programing. I keep getting the error:
Fatal error: Uncaught Error: Call to a member function query() on null in C:\xampp\htdocs\learning\core\classes\core.php:11 Stack trace: #0 C:\xampp\htdocs\learning\core\classes\core.php(23): core->query('SELECT * FROM c...') #1 C:\xampp\htdocs\learning\core\classes\core.php(27): test->test() #2 C:\xampp\htdocs\learning\core\init.php(6): require('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\learning\core\classes\core.php on line 11
<?php
class core{
    protected $db, $results;
    private $rows;
    public function __construct(){
        $this->db = new mysqli('localhost', 'root','','test');
    }
    public function query($sql){
        $this->result = $this->db->query($sql);
    }
    public function rows(){
        for($x = 1; $x <= $this->db->affected_rows; $x++){
            $this->rows[] = $this->result->fetch_assoc();
        }
        return $this->rows;
    }
}
class test extends core{
    public function test(){
        $this->query("SELECT * FROM currentseason");
    }
}
  $test = new test();
    $test->test();
    ?>
 
     
    