Hello,
I can’t connect to my database. This my code to connect:
class Database
{
private $server = "localhost";
private $login = "id9551308_user";
private $password = "*****";
private $database = "id9551308_konzole";
public $conn;
public function dbConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=" . $this->dbserver . ";dbname=" . $this->dbname.";charset=utf8", $this->dbuser, $this->dbpass);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $exception)
{
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
$DB = new Database();
$conn = $DB->dbConnection();
I tried it with XAMPP and everything was working so whats wrong? Can somebody help me?