title: Access denied for user ''@'localhost' to database
body: <p>I get this error while connecting to database with php-class:<br>
  when try to connecting to database I get this:</p>
  
  <blockquote>
    <p>Warning: mysqli_connect() [function.mysqli-connect]: (42000/1044):
    Access denied for user ''@'localhost' to database 'pixels' in
    D:\AppServ\www\my\classes\db.class.php on line 15</p>
  </blockquote>
  
  <p>db.class.php :</p>
  
  <pre><code>    class DBclass{
      private $servern,$username,$password,$dbname,$connect;
      public function connectDB(){
          $this-&gt;servern = $this-&gt;get_servern();
          $this-&gt;username = $this-&gt;get_username();
          $this-&gt;password = $this-&gt;get_password();
          $this-&gt;dbname   = $this-&gt;get_dbname();
  
          $this-&gt;connect = mysqli_connect($this-&gt;servern,$this-&gt;username,$this-&gt;password,$this-&gt;dbname);
          if(!$this-&gt;connect){
              echo 'Error : Fail to connect to database !!';
          }
      }
  //=========================================================//
      public function set_servern($host){
          $this-&gt;servern = $servern;
      }
  
      public function set_username($user){
          $this-&gt;username = $username;
      }
  
      public function set_password($pass){
          $this-&gt;password = $servern;
      }
  
      public function set_dbname($dbname){
          $this-&gt;dbname = $dbname;
      }
  //===========================================================//
      private function get_servern(){
          return $this-&gt;servern;
      }
  
      private function get_username(){
          return $this-&gt;username;
      }
  
      private function get_password(){
          return $this-&gt;password;
      }
  
      private function get_dbname(){
          return $this-&gt;dbname;
      }
  }
  </code></pre>
  
  <p>connect.php :</p>
  
  <pre><code>include('./classes/db.class.php');
  $con = new DBclass();
      $con-&gt;set_servern('localhost');
      $con-&gt;set_username('root');
      $con-&gt;set_password('root');
      $con-&gt;set_dbname('pixels');
  
      $con-&gt;connectDB();
  </code></pre>
  
  <p>note : I am  using appserv</p>
  
  <blockquote>
    <p>AppServ 2.6.0 <br> Apache 2.2.8 <br> PHP 6.0.0-dev <br> MySQL 6.0.4-alpha
    phpMyAdmin-2.10.3</p>
  </blockquote>