title: How to create a connect with Sql database
body: <p>I am trying to connect my sql database to my php but there is an issue with the syntax of the &quot;created function to the database&quot;. Can someone help fix it.</p>
  <p>Here is the code</p>
  <pre><code>&lt;?php
  
  class Database {
  
      public $host = DB_HOST;
      public $user = DB_USER;
      public $pass = DB_PASS;
      public $dbname = DB_NAME;
  
      public $link;
      public $error;
  
      private function connectDB(){
  
  
  // here is the issue
  
          $this -&gt; link new mysqli($this -&gt; host, $this -&gt; user, $this -&gt; pass, $this -&gt; dbname);
  
          if(!$this-&gt;link){
  
              $this-&gt;error = &quot;connection fail&quot;.$this-&gt;link-&gt;connect_error;
              return false;
          }
      }
  
  } 
  
  ?&gt;
  </code></pre>