Php Mysqli Extension Is Missing Windows Drivers

Active3 years, 9 months ago

Enable Mysqli Extension

I installed Apache, PHP 5.6 and MySQL 5.7 on a Windows server.

Windows Only Extensions. Overview of the MySQL PHP drivers. PHP 7 removes the mysql extension, leaving only the latter two options. Windows Only Extensions. Mysqli_driver::embedded_server_end — Stop embedded server. The mysqli Extension and Persistent Connections. MySQL native driver for PHP - mysqlnd. The mysqlnd library is a php.net compile time default to all PHP MySQL extensions. Also, the php.net Windows team is using.

In php.ini, I enabled the following:

(And restarted Apache)

But when I try to use PDO in my php page, it still throws the error:

Windows Only Extensions XML Manipulation GUI Extensions. (no note 'exists as of X.X'), but I found the constant missing on an installation with PHP 5.2. After switching the PHP version to 5.3.27 on the webspace the constant was available. Views or triggers of mysql 5.x versions from PHP instead of using mysqli extension. On Windows, for PHP versions 5.3 and newer, the mysqli extension is enabled and uses the MySQL Native Driver by default. This means you don't need to worry about configuring access to libmysql.dll. The mysqli extension was introduced with PHP version 5.0.0. The MySQL Native Driver was included in PHP version 5.3.0. >On Windows, PHP is most.

What do I have to do to get PDO installed?

Don Rhummy
Don RhummyDon Rhummy
11.4k23 gold badges97 silver badges195 bronze badges

2 Answers

The problem was the extension_dir directive did not work as a relative path. Changing from extension_dir='ext' to extension_dir='c:/phpinstall_path/ext' fixed the problem.

Don RhummyDon Rhummy
11.4k23 gold badges97 silver badges195 bronze badges

In my apache httpd.conf I have (note I have # as remmed out because it took me 1 hour at least). So I left it to show me how not to do it.

In the above folder (and seen below) I have these files:

And in that same folder, in the php.ini file I have the following block that are pdo-related, with the ones in force not remmed out with a ;

;extension=php_pdo_firebird.dllextension=php_pdo_mysql.dll;extension=php_pdo_oci.dllextension=php_pdo_odbc.dll;extension=php_pdo_pgsql.dll;extension=php_pdo_sqlite.dll

then I have a phpinfo_xyz.phpfile for testing purposes only (read: delete it when you are done) that contains

Restart apache, point to that file from a browser and notice the following blocks similar to the following three.

...

...

In the first PHP picture above from phpinfo(), it was the getting the path right in httpd.conf that took the longest. That is why I left in the wrong path attempts seen in this Answer.

So it wasn't until Loaded Configuration File showed up decent that it had a chance.

Good luck. It was not fun. Half the problem was there were like 2 or 4 options of which original download to perform. Sadly I think it took me 2 or 3 hours all together. But I am not as smart as the rest of you.

DrewDrew
22.7k9 gold badges34 silver badges64 bronze badges

Not the answer you're looking for? Browse other questions tagged phpmysqlwindowspdowamp or ask your own question.

Active1 year, 5 months ago

I upgraded to PHP 5.3, and noticed that php_mssql.dll is missing. After googling a bit, it seems that 5.3 has dropped support for mssql. So I downloaded the drivers from microsoft, but I can't seem to get it to work.

I am on windows. What do I need to do, after I unzip the files in the ext directory of my PHP 5.3?

MachavityPhp Mysqli Extension Is Missing Windows Drivers
25.3k15 gold badges63 silver badges83 bronze badges
user187809

2 Answers

Quoting http://php.net/manual/en/intro.mssql.php:

The MSSQL extension is not available anymore on Windows with PHP 5.3 or later. SQLSRV, an alternative driver for MS SQL is available from Microsoft: » http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.

Once you downloaded that, follow the instructions at this page:

In a nutshell:

Put the driver file in your PHP extension directory.
Modify the php.ini file to include the driver. For example:

Restart the Web server.

See Also (copied from that page)

The PHP Manual for the SQLSRV extension is located at http://php.net/manual/en/sqlsrv.installation.php and offers the following for Installation:

The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The SQLSRV download comes with several driver files. Which driver file you use will depend on 3 factors: the PHP version you are using, whether you are using thread-safe or non-thread-safe PHP, and whether your PHP installation was compiled with the VC6 or VC9 compiler. For example, if you are running PHP 5.3, you are using non-thread-safe PHP, and your PHP installation was compiled with the VC9 compiler, you should use the php_sqlsrv_53_nts_vc9.dll file. (You should use a non-thread-safe version compiled with the VC9 compiler if you are using IIS as your web server). If you are running PHP 5.2, you are using thread-safe PHP, and your PHP installation was compiled with the VC6 compiler, you should use the php_sqlsrv_52_ts_vc6.dll file.

The drivers can also be used with PDO.

GordonGordon
273k61 gold badges477 silver badges516 bronze badges

Download Microsoft Drivers for PHP for SQL Server. Extract the files and use one of:

You can see the Thread Safety status in phpinfo().

Add the correct file to your ext directory and the following line to your php.ini:

Use the filename of the file you used.

As Gordon already posted this is the new Extension from Microsoft and uses the sqlsrv_* API instead of mssql_*

Update:
On Linux you do not have the requisite drivers and neither the SQLSERV Extension.
Look at Connect to MS SQL Server from PHP on Linux? for a discussion on this.

Mysqli Extension Download

In short you need to install FreeTDS and YES you need to use mssql_* functions on linux. see update 2

To simplify things in the long run I would recommend creating a wrapper class with requisite functions which use the appropriate API (sqlsrv_* or mssql_*) based on which extension is loaded.

Update 2: You do not need to use mssql_* functions on linux. You can connect to an ms sql server using PDO + ODBC + FreeTDS. On windows, the best performing method to connect is via PDO + ODBC + SQL Native Client since the PDO + SQLSRV driver can be incredibly slow.

Community
danishgoeldanishgoel
3,2421 gold badge14 silver badges26 bronze badges