PHP7 does not work with SQL Server 2014

Asked

Viewed 1,366 times

2

I have a project running in Xampp with PHP 5.6 and SQL Server 2014 Express. I’m trying to migrate the project to PHP 7.1.0 but is giving error as shown below.

Erro PHP 7

I copied the dll to the ext folder of PHP which is in c: php7 ext. The four dll are showing error below.
I’m using Apache 2.4.23 and PHP 7.1.0.

extension=php_sqlsrv.dll
extension=php_pdo_sqlsrv.dll
extension=php_pdo_sqlsrv_7_ts.dll
extension=php_sqlsrv_7_ts.dll
  • Installed Microsoft Drivers 4.0 for PHP for SQL Server?

  • Quotation marks. Installing is a compressed file.

  • What you do is unzip dll in the ext folder and make php.ini see these dll.

  • That’s right; extract the contents of SQLSRV40.EXE from the extensions directory.

  • Blz. But why doesn’t it work? Do you have any idea what might be going on?

1 answer

3


PHP extension Dlls are compiled to work in a single version of PHP. The PHP 5.6 DLL will lock in PHP 7, and the PHP 7 DLL will lock in PHP 7.1. So, at first, make sure you’re using only the correct version in the ext and in the php.ini

Also note that PHP is compiled from two ways in Windows: thread safe and non thread safe. This also influences which extension you should use.

From PHP 7 we also have a compilation for x64 and another for x86. Again, you need to choose the correct version here too.

Assuming you’re using the version Thread Safe (the one that comes along with XAMPP/Apache generally), download the latest extension to work with SQL Server. The easiest way is to look at the Github driver repository, in the releases part and download only the version you want.

Today support for PHP 7.1 is still in preview, and the latest version that’s the one.

Download only the zip for PHP 7.1, choose the architecture, thread safe or not, and extract only them in the folder ext and insert into php.ini.

// suporte PDO
extension=php_pdo_sqlsrv_71_ts.dll
// sem PDO
extension=php_sqlsrv_71_ts.dll

Finally, if it doesn’t work out, you may need to update the Microsoft ODBC Driver 13 for SQL Server. SQL Server Express 2014 uses version 11 of this driver for connection, and so I don’t know if the new version of the PHP driver needs you to update ODBC as well.

  • I renamed my php folder from php7 to php7.1 I downloaded version 7.0.14 and followed step-by-step above that I had already done almost everything. The only thing I had not done is to update my obdc driver. I downgraded the version of php pq probably the dll I was using is for php 7.0. http://c92021ba.ngrok.io/teste.php

  • Look at my phpinfo on that link.

  • Fabricio, in your case try this version here with Pdo or unpublished. Choose with TS and try to update ODBC.

  • http://imgur.com/a/fumRX The weirdest I can’t even get the mysql Pdo enabled this time. I’ll do what you just asked me to do.

  • Look at this image. http://imgur.com/a/q8han It’s pointing to c: php and the correct one is c: php7 Several places are picking c: php by default.

  • 1

    The path in apache was wrong. It worked. Bye xampp. Thank you very much.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.