title: Fatal error: Call to a member function query() on null in C:\xampp\htdocs\tugas1\m_programKerja.php on line 43
body: <p>i know this question has been asked a lot, and i have been searching the answer to my question for days but i still havent found it yet.</p>
  
  <p>when i run index.php, it says Fatal error: Call to a member function query() on null in C:\xampp\htdocs\tugas1\m_programKerja.php on line 43. Am i getting the error because i havent inserted anything on my table on database? I did insert some data but i still got this error though...</p>
  
  <p>here's the code:
  koneksiMVC.php</p>
  
  <pre><code>&lt;?php
  $mysqli = new mysqli("localhost", "root", "", "praktikumweb");
  ?&gt;
  </code></pre>
  
  <p>m_programKerja.php</p>
  
  <pre><code>&lt;?php
  
  class m_programKerja {
  
  public $hasil = array();
  private $mysqli;
  
  public function __construct() {
      require 'koneksiMVC.php';
  }
  
  public function setPogramKerja($nomorProgram, $namaProgram, $suratKeterangan) {
      $rs = $this-&gt;mysqli-&gt;query( "INSERT INTO proker VALUES   
                                  ($nomorProgram,
                                   '$namaProgram',
                                   '$suratKeterangan')
                                  ");
  }
  
  public function hapusProgramKerja($nomorProgram) {
      $rs = $this-&gt;mysqli-&gt;query( "DELETE from proker WHERE 
                                      nomorProgram = $nomorProgram
                                  ");
  }
  
  public function editProgramKerja($nomorProgram, $namaProgram, $suratKeterangan) {
      $rs = $this-&gt;mysqli-&gt;query( "UPDATE proker 
                                      SET namaProgram = '$namaProgram',
                                          suratKeterangan= '$suratKeterangan'
                                      WHERE nomorProgram = $nomorProgram
                                  ");
  }
  
  public function getPogramKerja($nomorProgram) {
      $rs = $this-&gt;mysqli-&gt;query( "SELECT * FROM proker
                                      WHERE nomorProgram = $nomorProgram
                                  ");
      $this-&gt;hasil = $rs-&gt;fetch_array();
      return $this-&gt;hasil;
  }
  
  public function getSemuaPogramKerja() {
      $rs = $this-&gt;mysqli-&gt;query( "SELECT * FROM proker "); //this is line 43
  
      while ($row = $rs-&gt;fetch_assoc()) {
          $this-&gt;hasil[] = $row;
      }
      return $this-&gt;hasil;
  }
  }
  ?&gt;
  </code></pre>
  
  <p>and index.php</p>
  
  <pre><code>&lt;?php
  include_once("c_programKerja.php");
  $controller = new c_programKerja();
  if (isset($_GET['d'])) {
  $controller-&gt;delete($_GET['d']);
  } else if (isset($_GET['u'])) {
  $controller-&gt;viewUpdate($_GET['u']);
  } else if (isset($_GET['i'])) {
  $controller-&gt;viewInsert();
  } else {
  $controller-&gt;invoke();
  }
  ?&gt;
  </code></pre>