-1

I have reinstalled wamp server and getting this error.Im using php pdo to connect with database here is my code

<?php 

 class Database{
      private $dbname="mysql:host=localhost; dbname=ecom;";
      private $dbuser="root";
      private $dbpass="";
      public $conn;

    public function __construct(){
        if(!isset($this->conn)){
            try {
                $this->conn= new PDO("$this->dbname,$this->dbuser,$this->dbpass");
                $this->conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
                
            } catch (PDOException $e) {
                die("connection failed".$e->getMessage());
            }
        }
     }
    

}

?>

1 Answers1

-1
 <?php 

 class Database{
      private $dbname="mysql:host=localhost; dbname=ecom;";
      private $dbuser="root";
      private $dbpass="";
      public $conn;

    public function __construct(){
        if(!isset($this->conn)){
            try {
                $this->conn= new PDO($this->dbname,$this->dbuser,$this->dbpass);
                $this->conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
                
            } catch (PDOException $e) {
                die("connection failed".$e->getMessage());
            }
        }
     }
    

}

?>
RahulN
  • 218
  • 1
  • 5