0

I have windows 10 64 bit and installed xampp version 7.3 and I am trying to connect with SQL server using my below code but it always gives me that error:

"Uncaught Error: Call to undefined function sqlsrv_connect()".

I have downloaded ODBC versions 11,13,17 and I downloaded dll drivers and located them in my "xampp/php/ext". also I have changed the extension in my php.ini file and tried every single extension with different versions but nothing works! enter image description here

<?php


echo phpinfo();

$serverName = "ServerNAme"; //serverName\instanceName

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"DB[![enter image description here][1]][1]");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
         sqlsrv_close($conn);

}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>


Zhorov
  • 28,486
  • 6
  • 27
  • 52
MHassan
  • 25
  • 9
  • 3
    Do you see `sqlsrv` section in the `` output. This is a similar [Q&A](https://stackoverflow.com/questions/53664188/how-to-connect-sql-server-with-php-using-xampp/53680488#53680488). – Zhorov Jun 01 '21 at 14:47
  • Look at this, maybe helpful https://stackoverflow.com/questions/22015179/fatal-error-call-to-undefined-function-sqlsrv-connect – LordF Jun 01 '21 at 14:49
  • its a similar question but no answer worked. maybe I am wrong with the right extension should be in the php.ini but I dont know what should it be and i tried many extensions they all did not work – MHassan Jun 01 '21 at 14:50
  • There is also problem similar like this: https://stackoverflow.com/questions/44677399/call-to-undefined-function-sqlsrv-connect-troubleshooting – LordF Jun 01 '21 at 14:53
  • @Zhorov there is no sqlsrv – MHassan Jun 01 '21 at 14:53
  • 1
    You need to install PHP Driver for SQL Server in the PHP extension folder (`c:\xampp\php\ext\`). ODBC driver is a different installation and it's installation folder is not import.ant – Zhorov Jun 01 '21 at 14:53

0 Answers0