错误问题:
致命错误:未定义错误:调用C:\xampp\htdocs\DBtest\sqlsrv.php:7堆栈跟踪中的未定义函数sqlsrv_connect():#0 {main}抛出在第7行的C:\xampp\htdocs\DBtest\sqlsrv.php中
用于测试连接的PHP:
<?php
$serverName = "LAPTOP-NUUM4IGR\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"=>"perkuliahan");
$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));
}
?>PHP.ini文件:
extension=php_pdo_sqlsrv_74_nts_x64.dll
extension=php_pdo_sqlsrv_74_ts_x64.dll
extension=php_sqlsrv_74_nts_x64.dll
extension=php_pdo_sqlsrv_74_ts_x64.dll我的phpinfo上的pdo_sqlsrv显示得很好。扩展VER5.8.0+ 12928我已经安装了ODBCPHP7.4.10版本
以前我使用过SERVER 2008 R2,我想这是不合格的,所以我升级到Server 2012。但我还是犯了个错误?我非常感谢你的解决办法。
发布于 2021-01-13 07:46:45
MSSQL扩展在PHP 5.3或更高版本的Windows上不再可用。SQLSRV是MS的另一种驱动程序,可从Microsoft获得:
http://www.microsoft.com/en-us/download/details.aspx?id=20098
1.从http://www.microsoft.com/en-us/download/details.aspx?id=20098下载SQLSRV32.EXE (Microsoft驱动程序)
2.选择path: C:\xampp\php\ext
3.取消php.ini中的注释或追加扩展=php.ini
4.从XAMPP控制面板重新启动Apache (停止/启动)
我测试了它,它100%起作用
https://stackoverflow.com/questions/65697549
复制相似问题