gpt4 book ai didi

PHP SQL Server 无法连接

转载 作者:行者123 更新时间:2023-12-04 04:34:47 25 4
gpt4 key购买 nike

我想问一下如何使用PHP连接MSSQL Server 2005?

我得到这样的错误:

Connection could not be established. Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )



这是我的 PHP 代码:
<?php
$serverName = "192.168.183.249\MSSQLSERVER, 1542"; //serverName\instanceName, portNumber default is 1433)
$connectionInfo = array( "Database"=>"SEI_AproCS", "UID"=>"sa", "PWD"=>"");
$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 Driver

您可以按照此链接获取教程
PHP MSSQL Tutorial

另一种选择是使用 DSN 连接到 mssql ,
而这种简单的方法您只需在 php 中启用 mssql 扩展

并按照此链接创建 DSN Create DSN in windows

也可以按照此链接使用 php 和 DSN 进行连接
Connect php using DSN

关于PHP SQL Server 无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19924024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com