-3
<?php


class Database {

    private $host = 127.0.1;
    private $user = 'root';
    private $pass= '';
    private $dbname= 'myblog';

    private $dbh;
    private $error;
    private $stmt;


    public function __construct()
    {
        // set the DSN
        $dsn ='mysql:host='. $this->host . ' ;dbname= '. $this->dbname;
        // set options
        $options= array(
        PDO::ATTR_PERSISTENT  =>true,
        PDO::ATTR_ERRMODE      =>PDO::ERRMODE_EXCEPTION
        );
        // create new PDO
        try {
        $this->dbh= new PDO($dsn, $this->user, $this->pass, $options);

        }
        catch (PDOException $e){
           echo $e->getMessages();
            // echo "database problem";
        }
    }
}


?>
Phiter
  • 14,570
  • 14
  • 50
  • 84
ele_hrd
  • 1
  • 1
  • 2
    I don't know, might have something to do with `$host` not being a string and you adding two dots after it. – Phiter Feb 27 '18 at 13:05
  • 2
    The message you got shows exactly what your mistake was, I don't understand why people have time to create a new stackoverflow account and ask a question instead of trying to figure out wtf they did. – Phiter Feb 27 '18 at 13:06
  • Yes, $host should be a string... – Sebastien D Feb 27 '18 at 13:07

1 Answers1

-1

private $host should be string instead

private $host = "127.0.0.1";

Adlan Arif Zakaria
  • 1,706
  • 1
  • 8
  • 13