Why can I connect to a local SQL Server Express, but not to a remote SQL Server with PHP?

This is the standard code when using Windows Authentication:

<?php
    try {
        $conn = new PDO("sqlsrv:Server=geoffrey-pc\SQLEXPRESS;Database=books", 
                         NULL, NULL);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    } catch (PDOException $e) {
        echo $e;
        die("Error connecting to SQL Server");
    }

    echo "Connected to SQL Server\n";
?>

The above works for connecting to a local server (SQL Server 2008 Express Edition), but not for connecting to a server on the network (SQL Server Standard Edition). Error message:

exception "PDOException" with the message "SQLSTATE [28000]: [Microsoft] [SQL Server Native Client 10.0] [SQL Server] Login failed for user 'myDomain \ GEOFFREY-PC $'. 'in C: \ wamp \ www \ PhpProject1 \ index.php: 10 Stack trace: # 0 C: \ wamp \ www \ PhpProject1 \ index.php (10): PDO → __ construct ('sqlsrv: Server = n ...', NULL, NULL) # 1 { main}

, , , abc0120 \SQLEXPRESS - , . , , .

Apache 2.2.11. MSDN SQLServer 2005 Windows:

, ( ) -, SQL Server .

, .

SQL Server Management Studio, Windows.

+5
1

PHP :

<?php
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$user $password. null; , PHP , , ... , PHP , script (, ).

+2

All Articles