-1
Good evening, I am implementing my connection class with phpmyadmin, but I am receiving a denied access message, I have already checked the user, password and access permissions and it is correct. Could someone take a look at my code to see what might be wrong?
<?php
class Conexao {
private $host = null;
private $banco = null;
private $usuario = null;
private $senha = null;
public $conn = null;
public $sql = null;
public $result = null;
public function __construct($host, $banco, $usuario, $senha) {
$this->host = $host;
$this->banco = $banco;
$this->usuario = $usuario;
$this->senha = $senha;
}
public function __get($atributo) {
return $this->atributo;
}
public function __set($atributo, $valor) {
$this->$atributo = $valor;
}
public function conexaoComBanco() {
try {
$this->conn = new PDO("mysql:host=$this->host; dbname=$this->banco, '$this->usuario', '$this->senha'");
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo 'Conexão realizada com sucesso!';
} catch(PDOException $e) {
echo $e->getMessage();
}
}
}
$conexao = new Conexao('localhost', 'bancoteste', 'wilder', '12345');
$conexao->conexaoComBanco();
?>