无法将SQL Server身份验证与PHP共同连接

时间:2019-02-07 09:49:32

标签: php sql-server

我正在尝试用PHP连接SQL服务器。

我遵循了文档doc PHP,只是将其替换为商品数据,但是仍然存在此持久错误。

Array ( 
    [0] => Array ( 
        [0] => 28000 
        [SQLSTATE] => 28000 
        [1] => 18456 
        [code] => 18456 
        [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'xxxx'. 
        [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'xxxx'. 
    )

    [1] => Array ( 
        [0] => 42000 
        [SQLSTATE] => 42000 
        [1] => 4060 
        [code] => 4060 
        [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "xxxx" requested by the login. The login failed. 
        [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "xxxx" requested by the login. The login failed. 
    )

    [2] => Array ( 
        [0] => 28000 
        [SQLSTATE] => 28000 
        [1] => 18456 
        [code] => 18456 
        [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'xxxx'. 
        [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'xxxx'. 
    ) 

    [3] => Array ( 
        [0] => 42000 
        [SQLSTATE] => 42000 
        [1] => 4060 
        [code] => 4060 
        [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "xxxx" requested by the login. The login failed. 
        [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "xxxx" requested by the login. The login failed. 
    )
)

没关系,我了解出了什么问题,但是我敢肯定,我可以正确替换数据。

查看我的PHP数据库连接:

<?php
$serverName = "myservername\\sqlexpress, 1433";     
$connectionInfo = array( 
    "Database"=>"DBname", 
    "UID"=>"login/connection", 
    "PWD"=>"password"
);

$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));
}
?>

0 个答案:

没有答案