qwertzuiop
qwertzuiop

Reputation: 735

Call to undefined function sqlsrv_connect() with WAMP

I know that this question has already been asked several times on this website but I'm seriously starting to wonder wheter I'm crazy or not.

My configuration : WampServer 2.5 64bits (PHP 5.5.12, Apache 2.4.9)

My steps:

  1. Download Microsoft Driver SQLSRV32.exe from https://www.microsoft.com/en-us/download/details.aspx?id=20098
  2. Extract the files from the .exe downloaded on my desktop
  3. Copy php_sqlsrv_55_ts.dll and php_pdo_sqlsrv_55_ts.dll into C:\wamp\bin\php\php5.5.12\ext
  4. Edit C:\wamp\bin\php\php5.5.12\php.ini adding "extension=php_pdo_sqlsrv_55_ts.dll" and "extension=php_sqlsrv_55_ts.dll"
  5. Edit C:\wamp\bin\apache\apache2.4.9\bin\php.ini adding "extension=php_pdo_sqlsrv_55_ts.dll" and "extension=php_sqlsrv_55_ts.dll"
  6. Restart all services (I even tried to restart my computer, but nothing works)

I still get the error... So what am I missing to make this work ?

Upvotes: 5

Views: 5787

Answers (6)

Tobi Dada
Tobi Dada

Reputation: 1

It'll work with 64 or 32 bits just download the right dll file for your operating system and update your php.ini file.

Upvotes: 0

Karol
Karol

Reputation: 1

Make sure to use php_error.log ( wamp->php->php error log ).

And php_sqlsrv_7_ts_x64.dll, php_pdo_sqlsrv_7_ts_x64.dll is working with the 7.0.29 version of PHP, but not with 7.2.4.

And Restart of Services is not enough, exit and run Wamp.

Upvotes: 0

Ramesh
Ramesh

Reputation: 1

Detailed steps for SQL Server Lovers to Install and Configure PhP:

  1. Install Wamp wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe
  2. Configure PhP a. Update conf file Thumbrules are i. Change Port ii. Change from Deny to Granted iii. Change from None to Allow iii. Change the order from Deny, Allow to Allow, Deny

    C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
    Line # 62, 63
    Listen 127.0.0.1:8201
    Listen [::0]:8201
    
    Line # 240
    <Directory />
        AllowOverride all
        #Require all granted
        Order allow,deny
        Allow from all
    </Directory>
    
    Line #274
    AllowOverride all
    
    Line #282
        Order allow,deny
        Allow from all
    Line #299
    Require all granted
    

    b. If Wamp is running, exit and restart c. type http://localhost:8201/ in browser, to get wamp home page d. place any sample html page in c:\wamp\www folder http://localhost:8201/pagename.html

  3. SSSP, create a Directory - project name, keep .zip file, config.xml, sssp_config.xml, widgets.ino files in this folder http://hostname:8201/DirectoryName in URL Launcher to install Widgets in SSSP TV Read SSSP Configuration file for more details on SSSP
  4. SQL Server Configuration Current Configuration WampServer 2.5 32bits [64 bits success story for SQL Server is less] PHP 5.5.12 Apache 2.4.9

    Steps:
    
    a. Download Microsoft Driver SQLSRV32.exe from https://www.microsoft.com/en-us/download/details.aspx?id=20098. 
    b. Extract the files from the .exe downloaded on my temp folder
    c. Copy php_sqlsrv_55_ts.dll and php_pdo_sqlsrv_55_ts.dll into C:\wamp\bin\php\php5.5.12\ext folder
    d. Or Copy dlls from DLL folder to C:\wamp\bin\php\php5.5.12\ext folder
    e. Edit C:\wamp\bin\php\php5.5.12\php.ini add
        extension=php_pdo_sqlsrv_55_ts.dll
        extension=php_sqlsrv_55_ts.dll
    f. Edit C:\wamp\bin\apache\apache2.4.9\bin\php.ini add 
        extension=php_pdo_sqlsrv_55_ts.dll
        extension=php_sqlsrv_55_ts.dll
    g. Install Microsoft® ODBC Driver 11 64 bit or 32 bit as per your OS. My OS is 64 bit. The ODBC drivers can be found @ https://www.microsoft.com/en-us/download/details.aspx?id=36434 or in the folder ODBC
        And newer drivers can be found @ https://www.microsoft.com/en-us/download/details.aspx?id=20098
    e. Restart all services / Restart computer
    f. Place Sample php files in c:\wamp\www\TestWeb folder and browse http://localhost:8201/TestWeb/page.php
    g. Change host name, db name, uid and pwd as per your SQL server credentials
    

Upvotes: 0

RiggsFolly
RiggsFolly

Reputation: 94642

Installing just the PHP extension is not enough, you also need to install Microsoft® ODBC Driver 11 for SQL Server® - Windows

The ODBC drivers can be found here

And newer drivers can be found here

Also the best way to ensure you are editing the correct php.ini file is to use the wampmanager menus. So in future do :-

wampmanager -> PHP -> php.ini

This will load the correct php.ini into yoru editor.

C:\wamp\bin\php\php{version}\php.ini is used only by PHP CLI

C:\wamp\bin\apache\apache{version}\bin\php.ini is used only by PHP when running under Apache

Upvotes: 2

qwertzuiop
qwertzuiop

Reputation: 735

I finally found what was causing the problem. My Wamp was in 64 bits but the sqlsrv driver only works with 32 bits version. Now it works perfectly.

Upvotes: 2

Thomas F.
Thomas F.

Reputation: 36

Did you try to modify php.ini using the wamp interface ?

I know it sounds strange but sometimes the result is different than editing directly the file using the browser. Wamp manages those files in a strange way, give it a try...

Upvotes: 1

Related Questions