PDO "could not find driver" avec MariaDB
Bonjour,
Problème qui me rend fou : j'essaie de commencer à coder la partie de mon projet qui va se connecter à une base de donnée que j'ai créée sur MariaDB (que j'ai installé en local).
La BDD en question est accessible avec DBeaver, tout fonctionne.
Sauf que PHP est incapable de fonctionner.
Le code suivant (je ne mets pas tout, vous devez me faire confiance concernant les variables créées en amont) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| try {
$dsn = "mysql:host={$dbHost};dbname={$dbName}";
$pdo = new PDO($dsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Database connection successful
echo "Connected to the database successfully!";
} catch (PDOException $e) {
// Log the error, do not expose sensitive details to the user
error_log("Database connection error: " . $e->getMessage());
echo $e->getMessage()."<br/>";
die("An error occurred during database connection.");
} |
Entraîne un message "could not find driver" dans ma page.
Si j'accède à phpinfo() j'ai :
Code:
1 2
| PDO support enabled
PDO drivers no value |
Je viens de passer 1h à chercher des retours de ce problème sur le web,sans succès. Tous ne parlent que d'activer :
Code:
1 2
| extension=pdo_mysql
extension_dir = "ext" |
Puis de redémarrer Apache, ce que j'ai fait mais sans succès.
EDIT :
J'ai une série d'erreur Apache :
Code:
1 2 3 4 5 6 7
|
Cannot load Zend OPcache - it was built with configuration API420230831,NTS,VS16, whereas running engine is API420230831,TS,VS16
PHP Warning: PHP Startup: bz2: Unable to initialize module\nModule compiled with build ID=API20230831,NTS,VS16\nPHP compiled with build ID=API20230831,TS,VS16\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: exif: Unable to initialize module\nModule compiled with build ID=API20230831,NTS,VS16\nPHP compiled with build ID=API20230831,TS,VS16\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: mysqli: Unable to initialize module\nModule compiled with build ID=API20230831,NTS,VS16\nPHP compiled with build ID=API20230831,TS,VS16\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module\nModule compiled with build ID=API20230831,NTS,VS16\nPHP compiled with build ID=API20230831,TS,VS16\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: zip: Unable to initialize module\nModule compiled with build ID=API20230831,NTS,VS16\nPHP compiled with build ID=API20230831,TS,VS16\nThese options need to match\n in Unknown on line 0 |