title: PHP Fatal error: Call to a member function fetch_assoc() on string
body: <p>Can anyone help me solve this?  I having this line code with error of </p>
  
  <blockquote>
    <p>PHP Fatal error:  Call to a member function fetch_assoc() on string in
    C:\inetpub\wwwroot\dbcontroller.php on line 26</p>
  </blockquote>
  
  <p>Line 26 is this line of code: $result = $query->fetch_assoc();</p>
  
  <pre><code>&lt;?php
  class DBController {
  private $host = "localhost";
  private $user = "root";
  private $password = " ";
  private $database = "test";
  
  function __construct() {
      $conn = $this-&gt;connectDB();
      if(!empty($conn)) {
          $this-&gt;selectDB($conn);
      }
  }
  
  function connectDB() {
      $conn = mysqli_connect($this-&gt;host,$this-&gt;user,$this-&gt;password);
      return $conn;
  }
  
  function selectDB($conn) {
      mysqli_select_db($conn,$this-&gt;database);
  }
  
  
  function runQuery($query) {
      $result = $query-&gt;fetch_assoc();
      // $result = mysqli_query($query);
      while($row=mysqli_fetch_assoc($result)) {
          $resultset[] = $row;
      }       
      if(!empty($resultset))
          return $resultset;
  }
  
  function numRows($query) {
      $result  = mysqli_query($query);
      $rowcount = mysqli_num_rows($result);
      return $rowcount;   
  }
  }
  ?&gt;
  </code></pre>