Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install SQLSRV extension for PHP on WAMP

I've seen many of these posts and have looked through them all, but I still cannot get the SQLSRV extension running. Can you help me out? I will post all the information I have below:

  • Windows 7 64-bit
  • WampServer 2.2 32-bit
  • PHP 5.4.3 32-bit
  • Apache 2.2.22 (can't tell if VC6 or VC9)
  • Microsoft SQL Server 2012 Native Client 64-bit

I downloaded SQLSRV30.exe. I extracted the dll files to C:\wamp\bin\php\php5.4.3\ext.

In my php.ini:

  • extension_dir = "c:/wamp/bin/php/php5.4.3/ext/"
  • extension=php_sqlsrv_54_ts.dll
  • extension=php_pdo_sqlsrv_54_ts.dll

I know that SQLSRV30.exe is built as 32-bit. This is why I have 32-bit versions of Wamp and PHP. I also know that nothing in Wamp is non-thread-safe.
If I view phpinfo() I should see a 'sqlsrv' section, but I currently do not.

What am I doing wrong?

like image 919
user1971193 Avatar asked Mar 29 '13 18:03

user1971193


People also ask

How enable Sqlsrv in PHP INI?

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 8 driver files, four of which are for PDO support. The most recent version of the driver is available for download here: » SQLSRV download.

What is Pdo_sqlsrv?

PDO_SQLSRV is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MS SQL Server (starting with SQL Server 2005) and SQL Azure databases.


3 Answers

If you are editing c:\wamp\bin\php\php.ini, do not edit that file just edit the one given by wamp server php.ini file, goto wamp server php, then php.ini then you get write ini file.

I had the same problem, this fixed it for me.

Also, make sure you right click WAMP shortcut and "Run as Administrator"

like image 142
user3051218 Avatar answered Oct 18 '22 00:10

user3051218


I ran into some trouble this morning, but I found out I had a x64 WampServer... Which was not gonna work correctly.

So, I reinstalled a x86 WampServer, and followed everything i could find on PHP.net (http://php.net/manual/en/sqlsrv.requirements.php). Because I saw this post while i was looking for my x64 solution, I thought I would come back and try to help you:

1) If you have PHP 5.4.# on Wamp, i bet it's TS,VC9

2) Locate the correct 'php.ini' : mine is NOT in the 'bin/php#' folder, but in the 'bin/apache#' folder (C:\wamp\bin\apache\apache2.2.22\bin\php.ini)

3) There are 2 SQLSRV driver versions, 2.0 and 3.0 , make sure you have 3.0!

From the looks of it, we have exactly the same Wamp version, so... I'm pretty sure you have to use the 'php_sqlsrv_54_ts.dll' and 'php_pdo_sqlsrv_54_ts.dll'.

like image 22
André Seppenwoolde Avatar answered Oct 17 '22 23:10

André Seppenwoolde


Did you see your new dll in your php extensions list? If so, click on it and make sure there is a V by its name. (left click on the hopefully green wamp symbol. php-->php extensions-->name of your dll)

I had a similar problem with php 5.5, SQLSRV31.exe, php_sqlsrv_55_nts.dll and php_sqlsrv_55_ts.dll. Miraculously it worked.

like image 34
kishu Avatar answered Oct 18 '22 00:10

kishu