我通常将我的 SQL Server 与 SQL Server Management Studio 一起使用。在那里登录时,我使用 Windows 身份验证并且不指定用户名/密码。因此,我目前使用的用户名/密码与登录计算机时使用的用户名/密码相同。我正在尝试通过 PHP 建立与服务器的连接;但是,我得到一个错误。有人知道我在做什么错吗?
代码
$serverName = "MYPCNAME";
$connectionInfo = array( "Database"=>"College", "UID"=>"MYUSERNAME", "PWD"=>"MYPASSWORD");
$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));
}
错误
Connection could not be established.
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'MYUSERNAME'. ) )