私は通常、SQL Server Management Studio で SQL Server を使用しています。そこにログインするときは、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'. ) )