使用MS SQL将PHP连接到Microsoft Windows 2012 R2 Server

时间:2017-05-01 17:56:27

标签: php sql sql-server sql-server-2012 connection

我需要连接到我的虚拟机。该计算机在Windows 2012 R2 Standard上运行。安装很干净,防火墙已经设置为关闭。现在是我无法用密码连接的问题。服务器名称为APP01,用户名为@ Welkom1。这是我在XAMPP上运行的PHP代码。

$server = "APP01\SQLEXPRESS";$options = array(  "UID" => "APP01\Administrator",  "PWD" => "@Welkom1",  "Database" => "hetboekje");
$conn = sqlsrv_connect($server, $options);
if ($conn === false) die("<pre>".print_r(sqlsrv_errors(), true));
echo "Successfully connected!";sqlsrv_close($conn);

运行此代码时出现此错误:

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

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

)

我不明白为什么这段代码没有连接? 有人能帮帮我吗?

0 个答案:

没有答案