I am unable to configure the sqlsrv drivers in php7

Asked

Viewed 1,111 times

4

In the archive php.ini all extensions are found, except the ones I need to connect to SQL Server database.

extension=php_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll

As .dll are in the folder C:\php7\ext.

In the php.ini is mapped:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:\php7\ext"

When I execute php.exe, it returns the following message:

the procedure entry point call_user_function could not be locale in the dynamic library C:\php7\ext\php_pdo_sqlsrv_7_ts_x64.dll
the procedure entry point call_user_function could not be locale in the dynamic library C:\php7\ext\php_sqlsrv_7_ts_x64.dll

  • Did you install apache and php seperados? which versions? and which platform (x86 or x64)

  • @rray could add these details (x86, x64) in his reply to formalize the dup

  • @Guilhermenascimento can yes, I think the problem of this question is another ... usually when you install some x64 program (in windows) always need to manually download some add-on (ex c++ 20xx Redistributable or related).

2 answers

3

Download the package Microsoft Drivers for PHP for SQL Server and unzip into a folder and take these two files to the folder ext of :

To x86:

extension=php_sqlsrv_7_nts_x86.dll
extension=php_pdo_sqlsrv_7_nts_x86.dll

To x64:

extension=php_sqlsrv_7_nts_x64.dll
extension=php_pdo_sqlsrv_7_nts_x64.dll

Test the connection with:

$localhost = "localhost";
$database  = "testdb";
$user = "sa";
$pass = "12345";
$c = new PDO("sqlsrv:Server=$localhot;Database=$database", $user,$pass);

adjusting the settings of your seat.

References:

  • 1

    +1 But I would like you to further develop the answer, please. For example, how to set up the Windows pro folder in php.ini and how to include extensions in that file.

  • 1

    @Nottherealhemingway, then you can open as question, because, the installation of PHP will depend on the server you use, in my case for development I use IIS it already installs for me and puts in a folder C:\Arquivos de Programas\PHP, but, in the past, I did a lot of installation in the APACHE It was a lot of work, but it was rewarding. If I put this in the answer it will change the focus a lot, please if you can open a question relating this question, focusing on the installation, explaining its reality ? Usually it is to download the package and install to the particular Server.

  • continuing: the installation of ext is quite simple inside the folder [tag:php] has the paw ext put the . dll (in the case of windows) and restart the server, and very simple.

2

I also had problem and I could not this way, I used the same PDO and it worked

  $p= new PDO('odbc:Driver={SQL Server};Server=NOMEDOSERVER;Database=NOMEDOBANCO; Uid=LOGIN;Pwd=SENHA');

  $stmt = $p->prepare("SELECT *  FROM usuario");

Browser other questions tagged

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