我经历了几个问题和建议,以解决上述问题,但没有运气。
我有以下设置:
Windows Server 2008 R2
X
AMPP-win32-1.8.2-5-VC9的安装程序
SQLSRV30 - php驱动程序
sqlncli - Microsoft SQL Server 2008 R2 Native Client设置
我安装了其他所有内容,我在php.ini文件中有以下内容 下面的代码显示了php驱动程序所在的位置:
; On windows:
extension_dir="C:\xampp\php\ext"
以下是Windows扩展名
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_sqlsrv_54_ts.dll
当我检查phpinfo文件时,没有列出sqlsrv。我知道这可能意味着它没有安装,但已安装。
以下是php信息文件:
我还重启了apache和服务器。我错过了什么吗?
我收到以下错误:
调用未定义的函数sqlsrv_connect()
这是我用来连接的代码:我正在连接另一个托管SQL Server 2005的服务器
/Connection to SQL Server Database
error_reporting(E_ALL);
$serverName = "172.xx.x.xxx";
$connectionInfo = array('Database'=>'Eque', "UID"=>"develop", "PWD"=>"develop");
$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));
}
答案 0 :(得分:8)
我一直在努力完成整个过程,这才是最终奏效的。我使用PHP 5.4.16和Apache 2.4.4与Sql Express 2008 R2。
将文件移至本地文件夹
答案 1 :(得分:4)
将PHP驱动程序加载到php.ini文件中,然后重新启动服务器。
extension=php_sqlsrv_53_ts.dll
extension=php_pdo_sqlsrv_53_ts.dll
<强>参考:强> http://technet.microsoft.com/en-us/library/cc296203(v=sql.105).aspx
TS表示线程安全。发现您的服务器是线程安全的或非线程安全的
答案 2 :(得分:0)
在Windows 10 64bit和php 5.6上对我有用。是从这里下载的3.2版驱动程序:Microsoft SQL Server driver for PHP