1

I have the following code to connect to a Mysql database from my local PHP (Windows, using IIS),

$dbhost     = "xxxx.database.windows.net";
$dbname     = "yyyy";
$dbuser     = "uuuu";
$dbpass     = "pppp";
$driver     = "sqlsrv";
$connection = new PDO("$driver:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);

php info says this:

Loaded Configuration File   C:\Program Files (x86)\IIS Express\PHP\v5.6\php.ini

I have the following in this php.ini file

[WebPIChanges]
error_log=C:\Windows\temp\PHP56ForIISExpress_errors.log
upload_tmp_dir=C:\Windows\temp
session.save_path=C:\Windows\temp
cgi.force_redirect=0
cgi.fix_pathinfo=1
fastcgi.impersonate=1
fastcgi.logging=0
max_execution_time=300
date.timezone=Europe/Minsk
extension_dir="C:\Program Files (x86)\iis express\PHP\v5.6\ext\"

[ExtensionList]
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_curl.dll
extension=php_exif.dll
extension=php_xmlrpc.dll
extension=php_openssl.dll
extension=php_soap.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_imap.dll
extension=php_tidy.dll
extension=php_sqlsrv.dll

This file exists: C:\Program Files (x86)\IIS Express\PHP\v5.6\ext\php_pdo_mysql.dll

Why do I get a "could not find driver" error? My application pool can run 32-bit or 64-bit.

0

1 Answer 1

4

Two things were wrong. I had the wrong connection string. Should have been

$connection = new PDO("$driver:Server=$dbhost;Database=$dbname",$dbuser,$dbpass);

I was also missing the extension for sql server!!!

extension=php_pdo_sqlsrv_56_nts.dll

I didn't even have version 5.6 on my PC had to download it from here:

https://www.microsoft.com/en-us/download/confirmation.aspx?id=20098

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.