thebestpdowrapper
thebestpdowrapper copied to clipboard
PHP 7.1 Above - Fatal error: Uncaught PDOException: could not find driver in /home/project/public_html/api/v1/database-singleton.php:36
hi, my project works fine for PHP 7.0
but for PHP 7.1, 7.2 above, the PDO wrapper is not working:
Error:
Fatal error: Uncaught PDOException: could not find driver in /home/project/public_html/api/v1/database-singleton.php:36 Stack trace:
line 35 $dsn = 'mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset='.DB_CHAR;
line 36 self::$instance = new PDO($dsn, DB_USER, DB_PASS, $opt);
#0
/home/project/public_html/api/v1/database-singleton.php(36): PDO->__construct('mysql:host=loca...', 'db_name...', 'password', Array)
#1 /home/project/public_html/api/v1/database-singleton.php(41): DB::instance()
#2 /home/project/public_html/api/v1/all-notifications-v2.php(62): DB::__callStatic('prepare', Array)
#3 /home/project/public_html/api/v1/all-notifications-v2.php(1426): getAllUserNotification('4')
#4 {main} thrown in /home/project/public_html/api/v1/database-singleton.php on line 36
"Driver" is the database driver for MySQL, SQLite or other database you may be using. The driver needs to be enabled under Extensions in php.ini + restart your web server.
Sample extensions in php.ini:
;extension=pdo_firebird <- this driver is disabled, so Firebird will not work
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql <- this driver is disabled
extension=pdo_sqlite
I enabled
extension=pdo_pgsql extension=pgsql
but still got same error.
Excuse me please, but where is the php.ini file? Could anyone tell me where is this file located? Thank You
There is something wrong with people who developed php-7.*. In php.ini the extension was originally like this (I uncomented): extension=pdo_mysql After I renamed to match the dll filename it started to work: extension=php_pdo_mysql.dll
Thanks @gagrano, saved my day