【发布时间】:2016-06-01 15:25:21
【问题描述】:
我正在使用 2008 Server R2 平台上已经构建的数据库,我想创建一个应用程序来查询所述数据库。
我的所有经验都是本地安装 MySQL,但是这个数据库是 MS SQL server 10.50。
我的问题是, SQL 服务器是一个映射到 Web 服务器的驱动器,我已经安装了所有正确的 PHP 驱动程序和 SQLsrv 扩展,并且正在读取正确的 phpinfo,一切正常,但我对如何连接到 SQL 服务器感到困惑.澄清一下,
我的应用程序位于 Web 服务器上,我想通过 php 连接到映射到 Web 服务器的 SQL 服务器。我正在使用 Windows 身份验证。
目前我写的连接PHP是这样的
<?php
$serverName = "SmartCM.IMG";
$connectionInfo = array( "Database"=>"SMARTCM");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "I tried, but it didn't work out... sorry.<br /><br><br><br>";
die( print_r( sqlsrv_errors(), true));
}
?>
这是我读到的错误
Array (
[0] => Array (
[0] => 08001
[SQLSTATE] => 08001
[1] => 53
[code] => 53
[2] => [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53].
[message] => [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. )
[1] => Array (
[0] => HYT00
[SQLSTATE] => HYT00
[1] => 0
[code] => 0
[2] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired
[message] => [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired )
[2] => Array (
[0] => 08001
[SQLSTATE] => 08001
[1] => 53
[code] => 53
[2] => [Microsoft][ODBC Driver 11 for SQL Server]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][ODBC Driver 11 for SQL Server]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. )
)
【问题讨论】:
标签: php sql-server windows-server-2008-r2