0

I get PDOException could not find driver when connecting to mysql database with

$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);

on localhost on windows 10. I also tried replace localhost with 127.0.0.1.

phpinfo(): enter image description here

enter image description here

C:\php\php.ini:

extension_dir = "C:/php/ext"
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_exif.dll
extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8_12c.dll
;extension=php_openssl.dll
;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll

C:\Apache24\conf\httpd.conf:

LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"

php -m

[PHP Modules]
bcmath
calendar
Core
ctype
date
dom
ereg
filter
ftp
hash
iconv
json
libxml
mcrypt
mhash
mysql
mysqli
mysqlnd
odbc
pcre
PDO
pdo_mysql
Phar
Reflection
session
SimpleXML
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

C:\php\ext content:

25.10.2017  15:23            79 872 php_bz2.dll
25.10.2017  15:23            87 040 php_com_dotnet.dll
25.10.2017  15:23           478 208 php_curl.dll
25.10.2017  15:23            23 040 php_enchant.dll
25.10.2017  15:23            56 320 php_exif.dll
25.10.2017  15:23         2 874 880 php_fileinfo.dll
25.10.2017  15:23         1 504 768 php_gd2.dll
25.10.2017  15:23            48 128 php_gettext.dll
25.10.2017  15:23           359 936 php_gmp.dll
25.10.2017  15:23           911 360 php_imap.dll
25.10.2017  15:23            80 896 php_interbase.dll
25.10.2017  15:23           326 656 php_intl.dll
25.10.2017  15:23           218 624 php_ldap.dll
25.10.2017  15:23         1 413 632 php_mbstring.dll
25.10.2017  15:23            45 056 php_mysql.dll
25.10.2017  15:23           113 664 php_mysqli.dll
25.10.2017  15:23           147 456 php_oci8_12c.dll
25.10.2017  15:23           158 208 php_opcache.dll
25.10.2017  15:23           105 472 php_openssl.dll
25.10.2017  15:23            24 576 php_pdo_firebird.dll
25.10.2017  15:23            28 672 php_pdo_mysql.dll
25.10.2017  15:23            28 672 php_pdo_oci.dll
25.10.2017  15:23            24 576 php_pdo_odbc.dll
25.10.2017  15:23            39 936 php_pdo_pgsql.dll
25.10.2017  15:23           603 648 php_pdo_sqlite.dll
25.10.2017  15:23           117 760 php_pgsql.dll
25.10.2017  15:23            14 336 php_shmop.dll
25.10.2017  15:23           406 528 php_snmp.dll
25.10.2017  15:23           285 184 php_soap.dll
25.10.2017  15:23            68 608 php_sockets.dll
25.10.2017  15:23           761 856 php_sqlite3.dll
25.10.2017  15:23            38 912 php_sybase_ct.dll
25.10.2017  15:23           284 160 php_tidy.dll
25.10.2017  15:23            63 488 php_xmlrpc.dll
25.10.2017  15:23           285 696 php_xsl.dll

System Path:

C:\php
C:\php\ext
C:\Apache24
C:\Apache24/bin

Do I need any more drivers? Or is there any other problem?

If you need any more info I will provide it.

Thank you for any suggestions

0

2 Answers 2

4

Remove the ; from before the ;extension=php_pdo.dll. And also from before other pdo extensions. If you want to use those. And then restart the server.

The ; actually comments a line in ini files. So, you have to un-comment those lines to use them.

Edit: Instead of going through all of this trouble, you can instead use Xampp or Wamp or EasyPHP or something.

Sign up to request clarification or add additional context in comments.

10 Comments

I un-commented extension=php_pdo.dl and it is still the same, even if I uncomment every extension.
yes, i did restart using httpd -k stop and httpd -k start in C:\Apache24\bin
PDO drivers mysql, odbc, pgsql, sqlite
Do you have mysql server installed?
yes, I can access phpMyAdmin and make database
|
1

Please remove ; before ;extension=php_pdo.dll and restart the Apache server.

Here ; means commenting...so you need yo uncomment it by removing ;.

8 Comments

I un-commented extension=php_pdo.dl and it is still the same, even if I uncomment every extension.
restarted apache???
yes, i did restart using httpd -k stop and httpd -k start in C:\Apache24\bin
can you check by hard coding host,dbname,username,password $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password); in this
new PDO("mysql:host=localhost;dbname=db_iis", "user", "user");
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.