2013-11-29 69 views
0

我正在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'.))

任何人都知道這件事?非常感謝。真的很感激它。

+4

是不是登錄失敗的用戶'jason_SQLLogin''是一個很好的提示?密碼問題可能? – fvu

+0

是的,看起來像「jason_SQLLogin」沒有正確的憑據,訪問級別或別的東西。但這是一個非常簡單的憑證問題。 – JakeGould

+0

感謝球員,但似乎帳戶和密碼是正確的。因爲我用它來連接到ASP的mssql – Ben

回答

1

如果你說你有正確的用戶名/密碼,或許服務器(some.com)正在主動阻止與它的連接。

嘗試使用下面的步驟 -

  1. 論安全的SQL Server(的SOMEE​​),確保服務器 驗證設置爲SQL Server和Windows身份驗證模式。 這允許SQL服務器驗證用戶名和密碼。

  2. 配置服務器防火牆以允許連接到SQL服務器。