title: How can I get this mysqli database class working?
body: <p>I'll cut right to the chase. All I can achieve at this point with this class is a database connection. I am unable to make a query. Can you show me exactly how to get this working and/or show me how to recode it in a better way.</p>
  
  <pre><code>&lt;?php
  class database{
  
  public $dbHost = '';
  public $dbUser = '';
  public $dbPass = '';
  public $dbName = '';
  
  public $db;
  
  public function __construct(){}
  
  public function dbConnect(){
      $mysqli = new mysqli($this-&gt;dbHost, $this-&gt;dbUser, $this-&gt;dbPass, $this-&gt;dbName);
  
      /* check connection */
      if (mysqli_connect_errno()){
          printf("Connect failed: %s\n", mysqli_connect_error());
          exit();
      }else{
          echo 'connection made';
      }
      /* close connection */
      $mysqli-&gt;close();
  }
  
  public function query($sql){
      $query = $sql;
      self::preparedStatement($query);
  }
  
  public function preparedStatement(){
      if ($stmt = $mysqli-&gt;prepare($query)){
  
          /* execute statement */
          $stmt-&gt;execute();
  
          /* bind result variables */
          $stmt-&gt;bind_result($name, $code);
  
          /* fetch values */
          while ($stmt-&gt;fetch()) {
              printf ("%s (%s)\n", $name, $code);
          }
  
          /* close statement */
          $stmt-&gt;close();
      }
  }
  
  public function __destruct(){}
  
  }
  ?&gt;
  </code></pre>