PHP MSSQL extension not loaded in xampp [duplicate] - php

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?

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:
Loading the Microsoft Drivers for PHP for SQL Server
In a nutshell:
Put the driver file in your PHP extension directory.
Modify the php.ini file to include the driver. For example:
extension=php_sqlsrv_53_nts_vc9.dll
Restart the Web server.
See Also (copied from that page)
System Requirements (Microsoft Drivers for PHP for SQL Server)
Getting Started
Programming Guide
SQLSRV Driver API Reference (Microsoft Drivers for PHP for SQL Server)
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.

Download Microsoft Drivers for PHP for SQL Server. Extract the files and use one of:
File Thread Safe VC Bulid
php_sqlsrv_53_nts_vc6.dll No VC6
php_sqlsrv_53_nts_vc9.dll No VC9
php_sqlsrv_53_ts_vc6.dll Yes VC6
php_sqlsrv_53_ts_vc9.dll Yes VC9
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:
extension=php_sqlsrv_53_*_vc*.dll
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.
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.

Make sure to download the SQL driver here https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15
Then move in the two files with the same version as your php version. (check php -v)
In my case I was using version 7.4.30 and moved the php_pdo_sqlsrv_74_nts_x64.dll and
php_sqlsrv_74_nts_x64.dll into my php folder ext
C:\Program Files\php7.4.30\ext
Then open your php.ini file and add the extensions, remember to include ".dll
" on the extensions.
extension=php_pdo_sqlsrv_74_nts_x64.dll
extension=php_sqlsrv_74_nts_x64.dll
If you still have problems go to extension dir = "ext" in php.ini and replace ext with the exact path to your ext folder like this:
extension_dir = "C:\Program Files\php7.4.30\ext\"

Related

sqlsrv drivers doesn't appear on a WAMP server phphinfo() after adding the extension entries in the php.ini file

I wanted to setup a database connection from PHP to SQL server 2012.I have a wamp server(64 bit) set up on a windows machine(64 bit) with PHP 5.5.12 and on the same machine I have SQL server 2012 installed.
Extracted sqlsrv drivers from official_link
Copied the extracted drivers php_sqlsrv_55_ts.dll, extension = php_pdo_sqlsrv_55_ts.dll to php\ext folder, and then changed the php.ini file to include the extensions
extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;
Now I tried
<?php
phpinfo();
?>
I see the following information without any SQL server information in it.
Don't seem to have configured SQL server connection successfully. Could some one please guide me on what I am missing here.
64 bit WAMP server was not able to connect using the drivers extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;
So, I installed a 32 bit version of the WAMP server and it works fine now.
Check the php error log (c:\wamp\logs\php_error.log).
I had the same setup (64bit WAMP/PHP 5.5.12) and same missing sqlsrv reference in phpinfo and I got this error in my log:
PHP Warning: PHP Startup: Unable to load dynamic library
'c:/wamp/bin/php/php5.5.12/ext/php_pdo_sqlsrv_55_ts.dll' - %1 is not a
valid Win32 application. in Unknown on line 0
The solution was to install the 64bit version of the sqlsrv drivers. I found the unofficial 64bit drivers through http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html
Warning: In my testing I found these 64bit PHP_PDO_SQLSRV extension 10 times slower than when using PHP_PDO_ODBC.
I am visiting this thread and i think this might help full for you and other with the same issue:
How can I install pdo_sqlsrv on my windows 2008 Server 2008 R2?
The PDO Extension is not the same as the native driver Microsoft is offering. For PDO you must enable
extension=php_pdo_mssql.dll
in your php.ini.
{Normally this file (php_pdo_mssql.dll) should be in your PHP extension-directory (C:...\php\ext). If it's not there you can download PHP from http://windows.php.net/download/ and just take the extension from a package there (take one that correspond with your PHP version of course)}.
Above is taken from PDO MSSQL Server - Driver not found
read for more details. i have the same issue foe linux and i have saved all the pages thats why i am quoting for you help.
if all above didn't work for you then:
On the php.net it is listed that
On Windows, PDO_ODBC is built into the PHP core by default. It is linked against the Windows ODBC Driver Manager so that PHP can connect to any database cataloged as a System DSN, and is the recommended driver for connecting to Microsoft SQL Server databases.
http://php.net/manual/en/ref.pdo-odbc.php
You can connect to mssql server using odbc drivers as i have never connect by my self from windows i use to do it through linux using freeTds, following pages might help you
http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/
Connect PHP to MSSQL via PDO ODBC
PHP to SQL Server without ODBC or MSSQL support

Wamp2 x86 PHP 5.4 TS - sqlsrv module not loading

I see that many people had issues like that, however I could not find solution that would just work.
My phpinfo() says:
PHP Version 5.4.16
Server API Apache 2.0 Handler
Thread Safety enabled
I've downloaded: http://sqlsrvphp.codeplex.com/
readme says that if I have PHP 5.4 TS I should load those files:
php_sqlsrv_54_ts.dll
php_pdo_sqlsrv_54_ts.dll
I've loaded above, but only PDO extension seems to work fine:
PDO support enabled
PDO drivers mysql, sqlite, sqlsrv
pdo_sqlsrv support enabled
However I can not see sqlsrv extensions anywhere.
I've checked PHP error.log and it's also empty.
Do you have idea why those MS libs does not work and how can I debug it?
I've small project on Windows and configuring ones stack seems to be pretty hard comparing to Linux.

Installing MSSql Server 2008 Driver for PHP

I have installed Microsoft driver SQLSrv 3.0, installed it, gave the path to php extentions folder. Changed the Php.ini file to include the code
extensions=php_sqlsrv_53_nts_vc9.dll
But when i tried to check whether the drivers loaded by the phpinfo method, The info page doesnot include Sqlsrv section.
I m using Wamp server and windows 7.. php 5.3.6
It means drivers are not loaded. What can be the possible error . Any body help
SQLSRV 3.0 has the Microsoft Native Client 11 as a dependency. This is available for free from Microsoft. (It is also installed when you install SQL Server 2012.)
Try installing SQLSRV 3.0 using the Microsoft Web Platform Installer; that will probably address all of the dependencies for you.

Connection between MSSQL and PHP 5.3.5 on IIS is not working

I recently installed IIS, PHP 5.3.5 and MySQL, and had it all working.
I then has a requirement for MS SQL as well, and what I thought would be an easy task, is now driving me crazy and I can't figure out how to make it work.
According to php_info() the MS SQL drivers aren't loading.
I downloaded php_mssql.dll and enabled it in php.ini but it didn't work. I found out that the new version of PHP uses a different dll. So I downloaded the new one, put that in the ext folder, and updated the php.ini, but still no luck.
php_info() still isn't showing the drivers are loaded.
I am about to uninstall IIS and PHP, and install Apache, which I've installed before.
This question is my last attempt, can anyone help?
This is a snippet from a customer FAQ I wrote up a wee while ago to help our dedicated hosting customers get PHP up and running with the MS SQL Drivers. It may duplicate some knowledge already imparted in the comments above, but it's completeness may also help others starting from scratch:
Note: Clearly the PHP version numbers have moved on a bit since I wrote this but the general principles still apply.
Installation Pre-requisite:
The SQL Native Client is required for the Microsoft Drivers for PHP for SQL Server:
Microsoft SQL Server 2008 R2 Native Client X64 - for 64 bit Windows
or
Microsoft SQL Server 2008 R2 Native Client X32 - for 32 bit Windows
Download and install the Native Client driver that matches your system.
PHP MS SQL Drivers:
Download the Microsoft Drivers for PHP for SQL Server:
Microsoft Drivers for PHP for SQL Server
The file is a self-extracting executable so just use 7zip or WinRAR and extract the files to a folder of your choice. We now need to decide which driver to choose that matches your PHP installation.
PHP 5.3.5 comes in four different flavours:
PHP 5.3.5 Non-threadsafe VC9
PHP 5.3.5 Non-threadsafe VC6
PHP 5.3.5 Threadsafe VC9
PHP 5.3.5 Threadsafe VC6
To tell which version you have installed open the snapshot.txt file which lives in the same folder as php.exe, php-cgi.exe etc. Don't use notepad.exe because the file uses just line feed (\n) for line ends (unix format) at the start and notepad mangles these into a single line.
In the file you will see a line (around line 6, or near the middle of line 1 of you did use notepad) starting with: Build::
Build: D:\php-sdk\snap_5_3\vc9\x86\obj\Release - non-threadsafe, VC9 build
Build: D:\php-sdk\snap_5_3\vc6\x86\obj\Release - non-threadsafe, VC6 build
Build: D:\php-sdk\snap_5_3\vc9\x86\obj\Release_TS - threadsafe, VC9 build
Build: D:\php-sdk\snap_5_3\vc6\x86\obj\Release_TS - threadsafe, VC6 build
This tells us what version of PHP you're running.
From the folder you extracted the MS SQL PHP drivers, choose the driver(s) that matches the version of PHP being used (if you're not using PDO then you don't need to copy the php_pdo_ drivers):
PHP 5.3.5 Non-threadsafe VC9: php_sqlsrv_53_nts_vc9.dll, php_pdo_sqlsrv_53_nts_vc9.dll
PHP 5.3.5 Non-threadsafe VC6: php_sqlsrv_53_nts_vc6.dll, php_pdo_sqlsrv_53_nts_vc6.dll
PHP 5.3.5 Threadsafe VC9: php_sqlsrv_53_ts_vc9.dll, php_pdo_sqlsrv_53_ts_vc9.dll
PHP 5.3.5 Threadsafe VC6: php_sqlsrv_53_ts_vc6.dll, php_pdo_sqlsrv_53_ts_vc6.dll
Assuming your PHP installation lives in C:\PHP, copy (DON'T MOVE) these files to your C:\PHP\EXT folder.
Open C:\PHP\PHP.INI and locate the Dynamic Extensions part of the file and add:
extension=php_sqlsrv_53_nts_vc9.dll
extension=php_pdo_sqlsrv_53_nts_vc9.dll <-- optional
Finally, to be sure that PHP can find these extensions, ensure the extension_dir directive in C:\PHP\PHP.INI is set to C:\PHP\EXT:
extension_dir = C:\PHP\ext
Restart IIS and call phpinfo(). If all is well you should see:
And if you also loaded the PDO driver you should see:
The above mentioned:
extension=php_sqlsrv_53_nts_vc9.dll
extension=php_pdo_sqlsrv_53_nts_vc9.dll
what I found is incorrect.
Therefore, it is likely to be:
extension=php_sqlsrv_53_ts_vc9.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll

PHP (WAMP) OCI8 driver setup problem

Greetings,
I need to install oci8 drivers for PHP, but I’m having some trouble.
I already have a WAMP install, which comes with the oci8 extension, and have done the following in effort to set it up:
Enabled the extension by adding the following to my php.ini file in my Apache docroot as a local variable:
[PHP_OCI8]
extension=php_oci8.dll
Added my extensions directory path to my PATH environment variable on windows (c:/wamp/bin/php/php5.3.0/ext/;)
Added the same extensions directory to my php.ini file
When I start up my wamp I see the following error message:
PHP Startup: Unable to load dynamic library ‘c:/wamp/bin/php/php5.3.0/ext/php_oci8.dll’
I’m able to verify that the above path is correct, and am tempted to say that there’s something wrong with the .dll, but I’m not sure.
Has anyone experienced similar issues?
The Oracle OCI8 driver also requires that the Oracle Instant Client 10gR2 (aka 10.2.x) libraries or newer be installed on the machine PHP is running on. It is recommended you use either the Basic or Basic Lite version depending on if you need the internationalization libraries or not.
Win32 Instant Client Download Page
Win64 Instant Client Download Page
An annotation: I recently had the task of installing PHP 5 on a Windows system with Oracle HTTP Server 10g. PHP <= 5.0 requires an Oracle 8i or 9i client, PHP >= 5.1 requires an Oracle 10gR2 client or above. The Oracle HTTP Server 10g deploys an Oracle 10gR1 client which is not at all supported by PHP 5 (at least on Windows, maybe one can compile by himself...),
but contains PHP 4.3.9 as an Apache module. I couldn't use it: some PHP modules that are required need at least PHP 5.0.
Solution was: return to Oracle HTTP Server from the 9i companion CD while running a 10gR2 database in a separate Oracle Home.

Categories