title: PHP Database Class Error
body: <p>Below are the files that im using (trying) to pull information from a DB but it gives me an error.</p>
  
  <p>Config file:</p>
  
  <pre><code>define("DBHOST", "127.0.0.1");
  define("DBUSER", "root");
  define("DBPASS", "root");
  define("DBNAME", "test");
  define("DBPORT", "3306");
  </code></pre>
  
  <p>DB Class:</p>
  
  <pre><code>class Database{
  
      public function __contruct(){
          $con = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME, DBPORT);
  
          if (!$con){
              die("Error connecting to database");
          }
          else{
              $this-&gt;con = $con;
          }
      }
  
      function SimpleQuery(){
          $query="SELECT * FROM accounts";
          $array = $this-&gt;con-&gt;query($query);
          while ($fields = $array-&gt;fetch_array(MYSQL_ASSOC)){
              $values[] = $fields;
          }
          return $values;
      }
  }
  </code></pre>
  
  <p>Index file:</p>
  
  <pre><code>require ("config.php");
  require ("database.php");
  
  $db = new Database();
  
  echo $rows = $db-&gt;SimpleQuery();
  </code></pre>
  
  <p>Gives me this error:</p>
  
  <pre><code>Fatal error: Call to a member function query() on a non-object in database.php
  </code></pre>