1

I am trying to connect to a Azure data base. I have read many other stack overflow answers but they did not work for me:

-I have downloaded all the drivers that Azure offers to you. They are in

C:\wamp\bin\php\php5.5.12\ext folder: enter image description here

-I have added to the system variable the path to extensions folder.

-I have set the extension in both php.ini files (inside the apache and php folders).

-Extensions have been set like

extension=php_sqlsrv_5X_ts.dll
extension=php_pdo_sqlsrv_5X_ts.dll and like extension=C:/wamp/bin/php/php5.5.12/ext/php_sqlsrv_5X_ts.dll extension=C:/wamp/bin/php/php5.5.12/ext/php_pdo_5X_ts.dll

Where X means that I have tried 53, 54, 55 and 56.

-I restart all wamp services every single time that I try new changes.

-I have even tried with IISExpress.

-It is still giving me this error and I can't see "sqlsvr" when I use phpinfo().

what more I should do? I have been suffering this for weeks.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
Adrián Rodriguez
  • 430
  • 11
  • 26
  • The extension version should exactly match your PHP runtime version. If you are using non-thread-safe PHP 5.5, you should install `php_sqlsrv_55_nts.dll`. Could you please confirm your PHP version? – Gary Liu May 02 '16 at 01:36
  • Yes, I am using 5.5, you can see it in the question title and in the extensions path. I have tried with php_sqlsrv_55_nts.dll, but not only with that, I have tried also with the rest of the versions because it did not work. – Adrián Rodriguez May 02 '16 at 07:29
  • according your question description, you used `php_sqlsrv_5X_ts.dll` but not `php_sqlsrv_5X_nts.dll`. There different. Can you confirm this? – Gary Liu May 02 '16 at 07:43
  • I can't when I use that i get the error: PHP Startup: Unable to load dynamica library: http://prntscr.com/azw7aj – Adrián Rodriguez May 03 '16 at 19:47
  • When you got this error, it means you have used incorrect version library which mismatch with your system. You should check what your system version, e.g, if your system is on 64-bits, you should use X64 version of DLL libaray. Otherwise you need to use X86 version. – Gary Liu May 04 '16 at 01:05
  • Which should I choose? when you download the driver you have these options: http://prntscr.com/b1qxlx in their webpage [link](https://www.microsoft.com/en-us/download/details.aspx?id=20098). They does not specify wich one is for 64 bits I used 32 because it is supposed to be the most advanced one. – Adrián Rodriguez May 08 '16 at 18:06
  • You can match the OS and PHP version in the tables at https://msdn.microsoft.com/en-us/library/cc296170%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396 to find which version of driver you can use. And I'm using 3.2 version for WIN10 with PHP 5.6 – Gary Liu May 09 '16 at 01:15
  • I am using 3.2 version for WIN10 with PHP 5.5 and it does not work. – Adrián Rodriguez May 11 '16 at 19:49
  • Possible duplicate of [Fatal error: Call to undefined function sqlsrv\_connect()](http://stackoverflow.com/questions/22015179/fatal-error-call-to-undefined-function-sqlsrv-connect) – miken32 May 12 '16 at 15:47
  • No it is not duplicate, I have already tried that. If you read my question you will see that I have tried with the absolute path and it is still not working. – Adrián Rodriguez May 14 '16 at 09:37
  • Hi,@AdriánRodriguez, how is the situation now? Have you solved your issue? – Gary Liu May 18 '16 at 02:29
  • The situation is the same, I will try again this weekend to change my wamp php version (I tried the last day but it didn't work). I saw the table you put and 5.5.12 does not appear so maybe is because of that. – Adrián Rodriguez May 18 '16 at 11:58

2 Answers2

1

I use this XAMPP with PHP 5.5.34 at https://www.apachefriends.org/download.html to have the test to enable the sqlsrv extension of PHP.

You can refer my steps:

  1. After install the XAMPP application, run xampp-control.exe, click config=>PHP(php.ini) to check the extension folder.enter image description here
  2. Download the MSSQL driver for PHP in 3.2 version from https://msdn.microsoft.com/en-us/library/cc296170%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396. Uncompress it.
  3. Copy php_pdo_sqlsrv_55_ts.dll and php_sqlsrv_55_ts.dll from the uncompressed driver folder to the PHP extension folder (X:\xampp\php\ext in my scenario).
  4. Add extension=php_pdo_sqlsrv_55_ts.dll and extension=php_sqlsrv_55_ts.dll in PHP.ini file.
  5. Start Apache.

Meanwhile, you can use phpinfo() to check the setting of Loaded Configuration File and extension_dir to make sure whether you have configured the correct settings in the definite files and the DLL files in the right folder.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • I would like to do it with wamp since I use it in my job and sometimes I work from home using my PC. But I could try this as a last resort. – Adrián Rodriguez May 12 '16 at 09:17
  • Ok I was not able to do it work with wamp so I finaly installed xamp. Now sqlsrv_connect() works but I got Fatal error: Call to undefined function FormatErrors(). Any idea? – Adrián Rodriguez Jun 08 '16 at 19:51
  • It seem `FormatErrors()` is not a standard PHP function, you may check whether your files have been included completely, otherwise, you can try to use `var_dump(sqlsrv_errors())` instead. – Gary Liu Jun 10 '16 at 01:44
  • OK thank you very much it works! I have to check now if I can do all basic operations. Yesterday I had problems inserting data. – Adrián Rodriguez Jun 21 '16 at 06:26
1

I refer to the practice of Jordi's message in this post: Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs

xampp3.2.1 + php 5.5 + sql server 2014 Express, x64.

My situation is, transplant xampp folder to a brand new computer.

  1. Done all things need to do. (Download SQLSRV 5.6 (or 5.3 or..), check php.ini path, ...)
  2. Download and install OBDC Driver 13(x64) (or maybe you can try OBDC Driver 11(x64))
  3. Download and install SQL Server® 2014 Service Pack 3 (x64), need to restart the computer.
  4. Download and install Visual C++ Redistributable VS2012 Update4 (x86)
  5. Restart Apache

Then it can work!!!!!

I have been searching for a solution to this problem for several days and hope to help more people.

happybird
  • 74
  • 4