I have the below error -
Fatal error: Uncaught PDOException: could not find driver
When trying to connect via PDO.
<?php
$host = '127.0.0.1';
$db = 'mytodo';
$user = 'root';
$pass = 'root';
$charset = 'utf8mb4';
$options = [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_EMULATE_PREPARES => false,
];
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
try {
$pdo = new \PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
require ('index.view.php');
I've gone through countless instances of the same issue and all were resolved by uncommenting the "extension=php_pdo_mysql.dll" in php.ini, but it has made no difference for me.
I'm using Windows 10, MAMP and PHP 8.0.1
phpinfo() is showing no drivers under PDO
despite being uncommented in php.ini