问题
I installed xampp-win32-7.2.11-0-VC15-installer.exe, downloaded and extracted SQLSRV53.EXE to C:\xampp\php\ext, added
;extension=php_sqlsrv_72_ts_x64.dll
;extension=php_pdo_sqlsrv_72_ts_x64.dll
to php.ini and still get Uncaught Error: Call to undefined function sqlsrv_connect()
my code:
<?php
$serverName = "XXXXX\SQLEXPRESS"; //serverName\instanceName
// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"XXXX");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
回答1:
1) php_sqlsrv_72_ts_x64 AND php_pdo_sqlsrv_72_ts_x64 should be 32 bit same as xampp
2) Also compatible with PHP version
回答2:
In my case there were 2 php.ini files on wamp server. one of them is located at C:\wamp\bin\apache\Apachex.x.x\bin
folder and when i tried to connect through sqlsrv_connect
function, we are referring to the php.ini file in the apache folder.
So please check the php.ini in apache folder and enable the extension and test your connection with sqlsrv_connect.
Hope this will help.
来源:https://stackoverflow.com/questions/53041809/uncaught-error-call-to-undefined-function-sqlsrv-connect