简体   繁体   中英

PDO gives error “could not find driver”

<?
$dsn = 'mysqli:dbname=websiteusers;host=localhost';
$user = 'root';
$password = '123';

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Подключение не удалось: ' . $e->getMessage();
}
?>

It gives error could not find driver. What can i do?

As far as I know and the php docs for PDO are saying is that PDO doesn't support mysqli since there is an own class/adapter handling mysqli connections.

Supported PDO Drivers

MySQLi

Perhaps the PDO driver for mysql is not enabled on your server. Check your php.ini file for the following line:

;extension=php_pdo_mysql.dll

该驱动程序称为mysql,而不是mysqli。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM