Php Iis7 Mssql Call To Undefined Function Sqlsrv_connect
Solution 1:
I just had this problem myself. I finally got it fixed, so I figured I'd share.
The problem was that, although I had the sqlsrv dll installed (copied to my php/ext folder), and I had it added in my php.ini, in IIS, it was 'disabled'.
Here's some step by step instructions, in case anyone has this same problem again. (Or for future reference for me :))
Download (and install) the SQL Server drivers (.dll)
- Install them by running the .exe, and typing the path to your php extensions folder when it asks you where to decompress them.
- To find your current extension directory, run (cmd.exe)
php -i | more, and look for the lineextension_dir. (For me it was on the fourth press ofmore). Alternately, make a simple php file containing only<?php phpinfo(); ?>, and run it in the browser. This will give the same information, but in a much easier-to-read format.
- To find your current extension directory, run (cmd.exe)
- Install them by running the .exe, and typing the path to your php extensions folder when it asks you where to decompress them.
Add the extension to your php.ini
- To find the right php.ini, either run
php -i | moreagain, looking forLoaded Configuration File, or check that simple php script again (I highly recommend you make it - it'll save you time and effort). The path you find there is the file you need to edit. Add the following lines to your php.ini, and save it:
[PHP_SQLSRV] extention=php_sqlsrv_56_nts.dll
- To find the right php.ini, either run
Enable the extension in IIS Manager
- In the start menu, type
IIS Manager, and press enter. - Click on your Server's name in the left side bar
- Click
PHP Manager - Under
PHP Extensions, clickEnable or Disable an Extension. - If your extension is not under
Enabled, look underDisabledfor it. When you find it, right-click on it, and clickEnablein the context menu that appears.
- In the start menu, type
Test to make sure it worked
- Open that
phpinfo()page you made (you did, didn't you?), and look underRegistered PHP Streams. If you seesqlsrvin that list, you're set!
- Open that
Solution 2:
Your answer definitely helped me debug my problem. To add on to answer this question for others who may have successfully installed the PHP PDO SQLSRV .dll module but still get the same error.
It took me almost an hour to figure this out, but even after I configured PHP_PDO_SQLSRV, the function sqlsrv_connect() still didn't work.
Found out it's because if you are using the PDO sqlsrv extension, it has its own library with separate functions.
To connect to the database, you would do something like this:
$conn = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");You can view all of them here:
http://msdn.microsoft.com/en-us/library/ff628159(v=sql.105).aspx
If you are unsure of the differences between PDO and normal SQLSRV, please refer to this post:
SQLSRV driver vs. PDO driver for PHP with MS SQL Server
I chose PDO because I prefer data to be returned as strings (faster access for me instead of parsing the object/class types).
Solution 3:
I understand the situation.
I used PHP version above 5.4, so the use of PHP driver for Windows 3.0.
For this configuration, required client version of SQL 2012, but i have been the client SQL 2008 version
Problem solved.
Solution 4:
all you need to do is to download missed components like database manager and other like microsoft sql server 2008R2 management objects if you use sql server 2008 r2 and keep downloading till you get successed
Post a Comment for "Php Iis7 Mssql Call To Undefined Function Sqlsrv_connect"