gpt4 book ai didi

PHP SQL Server 2008 错误定位服务器/实例指定 [xFFFFFFFF]

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

我在将 Windows Apache 连接到 SQL Server Express 2008 时遇到问题

PHP 版本 5.2.9

Apache 版本 Apache/2.2.11 (Win32)

<?php
$serverName = "serverName\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
$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));
}
?>

我尝试使用 mssql 和 sqlsrv 驱动程序,但我无法连接到数据库。这些驱动程序已正确启用。 mssql configuration sqlsrv configuration

我可以连接到 sqlcmd 应用程序并成功执行查询:

sqlcmd -S serverName\SQLEXPRESS-U userName-P password

当我尝试连接 mssql 驱动程序时:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: serverName\SQLEXPRESS in C:\xampp\htdocs\ci\demo.php on line 12
Couldn’t connect to SQL Server on $myServer

When i try to connect with sqlsrv driver:

Connection could not be established.
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][SQL Server Native Client 10.0]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [message] => [Microsoft][SQL Server Native Client 10.0]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

最佳答案

我遇到了同样的问题,我使用了这段代码并且它已连接。数据库服务器是我的案例 10.105.88.99 在另一台机器上

 //i use sql server 2012

$serverName = '10.105.88.99';//only the server name
$connectionInfo = array( "Database"=>"mydbName", "UID"=>"myUserId", "PWD"=>"myPass");
$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 SQL Server 2008 错误定位服务器/实例指定 [xFFFFFFFF],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24180321/

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