1

First things first, I read and tried stuff I found online even from this website, but can't get it to work.

I have an SQL SERVER 2014 running on Windows Server 2012, there I have a WAMP 64 bits running Apache on PHP 7.1.6 and need to connect to the Database, apparently the extension is not loaded because I'm getting the undefined function error.

$conn = sqlsrv_connect( $APIDBSERVER, $connection);

What I've done so far:

  • Installed Microsoft® ODBC Driver 11 for SQL Server
  • Downloaded PHP SQL Driver 4.0 and moved php_sqlsrv_7_nts_x64.dll to /ext
  • Added them to php.ini: extension=php_pdo_sqlsrv_7_nts_x64.dll extension=php_sqlsrv_7_nts_x64.dll

Apparently the PDO also needs php_pdo.dll which WAMP doesn't have and I haven't found where to download it from, so I'm using the standard non-PDO approach

  • Recently even tried enabling odbc extensions which were disabled:

extension=php_odbc.dll

extension=php_pdo_odbc.dll

I access the php.ini through the WAMP menu so I know I'm editing the right one, restarted the server several times trying different things but I've run out of ideas.

Can you please help me?

EDIT: PHP error log indicates the modules couldn't be found, but if I check that path they're right there, copy&pasted filenames into php.ini.

PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.6/ext/php_pdo_sqlsrv_7_nts_x64.dll' - The specified module could not be found. in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.6/ext/php_sqlsrv_7_nts_x64.dll' - The specified module could not be found. in Unknown on line 0

EDIT 2: Tried downgrading to 7.0.20 and get the same error, so the php.ini is fine, it just won't load them for a reason, will try to download ODBC 13.1 maybe?

Pablo
  • 31
  • 3
  • Possible duplicate of [Fatal error: Call to undefined function sqlsrv\_connect()](https://stackoverflow.com/questions/22015179/fatal-error-call-to-undefined-function-sqlsrv-connect) – miken32 Sep 20 '17 at 20:53

2 Answers2

1

Each PHP version might require a different version of the Microsoft PHP Drivers for SQL Server.

The link below shows compatibility between PHP and MS SQLSRV versions: https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15.

0

Because of the way WAMPServer is configures, NTS extensions do not run.

So change your process just a little and use the Thread safe dll's instead.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • Gonna try that thanks. EDIT: I think it works, not getting the undefined function error so guess it's a yes, still have to check if it connects but sir I owe you a coffee! – Pablo Jul 03 '17 at 11:28