Undefined function sqlsrv_connect()


MySQL is more like a girl friend and cozy with WAMP.
MS SQL Server becomes the arrogent gal for WAMP. She does all the drama before falling in love with WAMP.

I know WAMP should not be preferred if you want to be away with MySQL. But many of us prefer in installing WAMP cause it comes with

  1. The desired PHP version
  2. Apache webserver is automatically taken care as compatible with your PHP 5.x.x version (You just cant put any Apache httpd with your PHP X)
  3. You get many required DLL files with installation to /ext folder like – C:\wamp\bin\php\php5.5.12\ext. Need not to download them from here and there.
  4. Ofcourse the GUI is so quick and easy to
    a) run/stop the services,    b) look for the PHP.ini for any changes,   c) look for the httpd.conf for any changes

See what happens when you try to work with SQL server into WAMP’s PHP
1. You need to download the DLL for SQL server supported by PHP
2. Make a change to php.ini file for this dll

Here is the step by step guideline from installation to troubleshoot:
A. Download the DLL file
1) Complete this table from your installed environment (done so far)
a) PHP Version – Something like 5.5.12 or 5.3.4 or ?
b) PHP dll –  Like php5ts.dll or php5.dll or ?  [ Look to the directory – C:\wamp\bin\php\php5.5.12]
c) Microsoft Driver Version -> ? ( We will do it in next few minutes)
d) Required SQL Server DLL file -> ? ( We will do it in next few minutes)

To get the 1c & 1d, launch the website – https://docs.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver

Your 1a & 1b are the key to find the c & d from this page and that is too critical to get the correct one. DONT BE IN HURRY!

2) Time to download the 1d) now from https://www.microsoft.com/en-us/download/details.aspx?id=20098. In the next screen after pressing “DOWNLOAD”,
select the right exe SQLSRV30.EXE/SQLSRV31.EXE/SQLSRV32.EXE/SQLSRV40.EXE
Those 30, 31, 32 or 40 are nothing but the 1c- Microsoft Driver Version

B. Changes to PHP.ini file
Look for the php.ini file into Apache folder, not the one at PHP folder – like C:\wamp\bin\apache\apache2.4.9\bin
Add these two lines at related place into the ini file as per your downloaded dll
    extension=php_sqlsrv_55_ts.dll
    extension=php_pdo_sqlsrv_55_ts.dll 
C. Restart the server
Are you still getting an error while running your PHP code – “Unable to find sqlsrv_connect()”

D. You are happy to GO – May be or No No No!
If so, issue could be with the dll and that is something more your OS as 32 bit or 64 bit.
Let us try to overcome this:
1. Download this Microsoft ODBC Driver 11 for SQL Sever
https://www.microsoft.com/en-us/download/details.aspx?id=36434
ENU\x64\msodbcsql.msi  -> 64 bit


Restart the WAMP and see if this brings a good luck to you. IF NOT
2. Here is the ROB’s page http://robsphp.blogspot.in/2012/06/unofficial-microsoft-sql-server-driver.html
which may bring a smile to your face.
Download the Unofficial Microsoft SQL Server Driver for PHP – https://onedrive.live.com/?id=669EE24817961774%21123&cid=669EE24817961774
and hope this should work for you.

Since this is unofficial, hence I am instructing to try into steps till A to D1. If fails then only go for D2.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s