3
I’m trying to make a connection to the bank by PDO, but every time I try to make this connection, the message appears:
could not find driver
I went back to find out and learned that I had to enable PDO in php.ini. OK, I went there and took the ; from where I needed, but still the message appears.
My code is this:
<?php
try{
// Faz conexão com banco de daddos
$pdo = new PDO("
mysql:host=localhost;
dbname=servidores;",
"root",
"root");
}catch(PDOException $e){
// Caso ocorra algum erro na conexão com o banco, exibe a mensagem
echo 'Falha ao conectar no banco de dados: '.$e->getMessage();
die;
}
?>
Does anyone know what it can be?
You restarted PHP after changing the
php.ini
? What operating system is using?– J. Bruni
@user2154508 Which version of php you are using? and which line was uncommented?
– rray
Which operating system you are using?
– bfavaretto
I am using Windows, and the version of my PHP is: PHP Version 5.2.6
– user2154508
Dude, are you sure you’re using PHP 5.2.6? If so, do you have a special reason? Otherwise, update this. It’s not the direct answer to your problem, but this version of is archaic.
– Emerson Rocha
Hello, can you tell what is the error returned ?
– Edilson
@Edilson is at the beginning of the question:
could not find driver
– Bacco
@user2154508 beyond the pdo_mysql line you set up the php extensions folder in the file . ini ?
– gmsantos