I am having trouble connecting to the database using PDO, I use MySQL.
When I run the connection to the database, the following error messages appear:
Fatal error: Uncaught exception 'PDOException' with message 'in C: \ wamp64 \ www \ phpCRUD \ config \ Conecta.php on line 11
PDOException: in C: \ wamp64 \ www \ phpCRUD \ config \ Connect.php on line 11
I do not know where I'm going wrong, could anyone help me?
Here is the code for the bank configuration:
<?php
require_once 'conf.php';
class Conecta extends conf{
var $pdo;
function __construct(){
$pdo = new PDO('mysql:host='.$this->host.':dbname='.$this->db, $this->usuario, $this->senha);
}
function login($email, $senha){
$stmt = $this->PDO->prepare("SELECT * FROM usuarios WHERE email = :email AND senha = :senha");
$stmt->bindValue(":email",$email);
$stmt->bindValue(":senha", $senha);
$exec = $stmt->execute();
$run = $stmt->fetchAll(PDO::FETCH_ASSOC);
return self::$run;
}
}
conf.php
<?php
class conf{
var $host = 'localhost';
var $usuario = 'root';
var $senha = '';
var $db = 'hoo';
}