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.

6
  • did u reset the server? Commented Mar 14, 2017 at 8:57
  • Do you mean a simple restart? Yes I also have done that. Commented Mar 14, 2017 at 8:58
  • Yes thats what I meant.... this will help u there was a smilar problem : stackoverflow.com/questions/30736601/… Commented Mar 14, 2017 at 9:00
  • Are you using sqlsrv 4.0 (downloaded from Microsoft's website)? If so, see my answer here Commented Mar 14, 2017 at 11:21
  • @ImClarky Yes I downloaded the 4.0 version. Now I also downgraded to php version 7.0 but it doesn't work as well. I don't have any idea why I get this error. Commented Mar 14, 2017 at 11:24

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer, but I already done this. I added it to the ext folder and registered it in the php.ini file.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.