An error occurred while connecting to MySQL with PDO & lt ;? Php & nbsp; $ dbms = 'mysql'; & nbsp; $ dbName = 'DB _ mrbook'; & nbsp; $ user = 'root'; & nbsp; $ pwd = '000000'; & nbs PDO connection to MySQL error
$ Dbms = 'mysql ';
$ DbName = 'DB _ mrbook ';
$ User = 'root ';
$ Pwd = '000000 ';
$ Host = 'localhost ';
$ Dsn = "$ dbms: host = $ host; dbname = $ dbName ";
Try {
$ Pdo = new PDO ($ dsn, $ user, $ pwd );
Echo "PDO connected to the database succeeded ";
} Catch (Exception $ e ){
Echo $ e-> getMessage ()."
";
}
?>
Show cocould not find driver at runtime
Modified php. ini. dist and php. ini. extension = php_mysql.dll, extension = php_pdo.dll and extension = php_pdo_mysql.dll are removed from the extension in recommended. If Apache is restarted, the same error occurs. please help me a lot.
------ Solution --------------------
Phpinfo () to check whether the load is successful
------ Solution --------------------
Check the load configure file in phpinfo () to see which php. ini file is loaded.
------ Solution --------------------
In this way, you can
PHP code
PDOPDO support enabled PDO drivers mysql, odbc, sqlite pdo_mysqlPDO Driver for MySQL enabled Client API version mysqlnd 5.0.8-dev-20102224-$ Revision: 308673 $ PDO_ODBCPDO Driver for ODBC (Win32) enabled ODBC Connection Pooling Enabled, strict matching pdo_sqlitePDO Driver for SQLite 3.x enabled SQLite Library 3.7.4
------ Solution --------------------
Whether the php. ini you changed is the php. ini corresponding to the Loaded Configuration File