我正在Somee服務器(somee.com)上使用PHP構建網站,並且使用Microsoft SQL和。現在我有一個問題,使PHP和SQL之間的連接。從PHP連接到Microsoft SQL的問題
這裏是我的連接代碼:
<?php
$serverName = "mssql.somee.com"; //serverName\instanceName
// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array("Database"=>"myDB","UID"=>"myusername","PWD"=>"mypassword");
$conn = sqlsrv_connect("mssql.somee.com", $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 'jason_SQLLogin'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'.) [1] => Array ([0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'.))
任何人都知道這件事?非常感謝。真的很感激它。
是不是登錄失敗的用戶'jason_SQLLogin''是一個很好的提示?密碼問題可能? – fvu
是的,看起來像「jason_SQLLogin」沒有正確的憑據,訪問級別或別的東西。但這是一個非常簡單的憑證問題。 – JakeGould
感謝球員,但似乎帳戶和密碼是正確的。因爲我用它來連接到ASP的mssql – Ben