1

I am trying to connect to a SQL Server with PHP, but unfortunately it fails with calling the function at self. I installed the drivers (DLL), as well a the driver from this site: https://www.microsoft.com/de-ch/download/details.aspx?id=36434

I am receiving the following message:

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in ....

I running a local server with XAMPP with the newest PHP version 7.1.1.

UPDATE:

I checked if the extension is loaded in PHP:

var_dump(extension_loaded ("php_sqlsrv_7_nts"));

But it gives me a bool(false) back.

Julian Schmuckli
  • 3,681
  • 11
  • 37
  • 64

1 Answers1

0

You have to install the MSSQL extension first and enable them. The is not working out of the box. What you have in your example is the ODBC driver but you need the PHP Extension in No Thread Safe Mode for your PHP-Version.

It's a bit complicated to find the correct extensions. Otherwise you can try to connect over ODBC but that make all a bit more complicated.

Try this:

https://learninglaravel.net/microsoft-drivers-for-php-7-for-sql-server-is-now-available

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • Thanks for your answer, but I already done this. I added it to the ext folder and registered it in the php.ini file. – Julian Schmuckli Mar 14 '17 at 08:54
  • Can you check if the Extension is loaded? It's possible that there are differents to PHP 7.1 and it's not working. And be sure that you use the Not Thread Safe version sorry my fault. – René Höhle Mar 14 '17 at 08:57