Home > OS >  XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection
XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Time:05-16

Edit: Solved the issue, for anyone facing this the solution is at the bottom.

I'm attempting to connect into a SQL Server DB I have hosted on my Linux VM. I'm running xampp on my development windows machine and the connection is coming from a php site I'm building. I figured I'd need to use sqlsrv to connect in. I downloaded the dll's from enter image description here

The other things I've tried was to use sqlsrv_connect instead of PDO. I found conflicting information on this working for my php version (8.1), but figured let's try it anyway. However when I run into that variant, I get:

Fatal error: Call to undefined function sqlsrv_connect()

It seems obvious to me my .dlls are not being recognized or something of the sort. However I cannot for the life of me understand why. I've verified everything is ran as admin, restarted xampp multiple times, removed/redownloaded the dlls, etc.

Can anyone point out any glaring problems I may not be thinking of?


EDIT: Solved. There were two problems.

  1. My Xampp installation was corrupt. It wouldn't recognize ANY new DLLs I noticed from using echo phpinfo(); on my page.

  2. The ini file configuration was attempting to use the x86 dll's instead of the x64's for some reason, even when the extensions were written in the ini as x64.

Steps to solve:

  1. I reinstalled and reconfigured Xampp with default settings once more, and dll's were now recognized.

  2. I removed the x86 dll's from the extensions directory of Xampp.

  3. The final php.ini is as such:

extension=php_sqlsrv_81_ts_x64.dll
extension=php_pdo_sqlsrv_81_ts_x64.dll
extension=php8ts.dll
extension=php_pdo_odbc.dll
extension=php_pdo.dll

Utilizing the final .dll may be redundant, but it still works as intended. Make sure you verify the correct version of sqlsrv or pdo_sqlsrv, as compatibility issues with your phpversion may occur.

CodePudding user response:

Solved. There were two problems.

  1. My Xampp installation was corrupt. It wouldn't recognize ANY new DLLs I noticed from using echo phpinfo(); on my page.

  2. The ini file configuration was attempting to use the x86 dll's instead of the x64's for some reason, even when the extensions were written in the ini as x64.

Steps to solve:

  1. I reinstalled and reconfigured Xampp with default settings once more, and dll's were now recognized.

  2. I removed the x86 dll's from the extensions directory of Xampp.

The final php.ini is as such:

extension=php_sqlsrv_81_ts_x64.dll
extension=php_pdo_sqlsrv_81_ts_x64.dll
extension=php8ts.dll
extension=php_pdo_odbc.dll
extension=php_pdo.dll

Utilizing the final .dll may be redundant, but it still works as intended. Make sure you verify the correct version of sqlsrv or pdo_sqlsrv, as compatibility issues with your phpversion may occur.

  • Related