none
Parse error: syntax error, unexpected ')' in C:\inetpub\wwwroot\info.php on line 14 ( SQL Server driver for PHP 1.1 )

    Question


  • <?php
    /*
    Connect to the local server using Windows Authentication and specify
    the AdventureWorks database as the database in use. To connect using
    SQL Server Authentication, set values for the "UID" and "PWD"
     attributes in the $connectionInfo parameter. For example:
    $connectionInfo = array("UID" => $uid, "PWD" => $pwd));
    $uid = "Administrator";
    $pwd = "Password1";
    $connectionInfo = array("UID" => $uid, "PWD" => $pwd));
    */
    $uid = "Administrator";
    $pwd = "Password1";
    $connectionInfo = array("UID" => $uid, "PWD" => $pwd));
    $serverName = "(localhost)";
    $connectionInfo = array( "Database"=>"dbase");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    if( $conn )
    {
         echo "Connection established.\n";
    }
    else
    {
         echo "Connection could not be established.\n";
         die( print_r( sqlsrv_errors(), true));
    }

    //-----------------------------------------------
    // Perform operations with connection.
    //-----------------------------------------------

    /* Close the connection. */
    sqlsrv_close( $conn);
    ?>


    Parse error: syntax error, unexpected ')' in C:\inetpub\wwwroot\info.php on line 14

    Thursday, December 17, 2009 1:32 PM

Answers

  • Hi Rajib,

     

    The code in MSDN includes a syntax error, but that error is in a section commented out. We should correct it anyway.

     

    I would like to draw your attention to another issue in your code. All the connection options have to be specified within a single array:

    $connectionInfo = array("UID" => $uid, "PWD" => $pwd, “Database”=>”dbase”);

     

    As it is now, the second assignment to $connectionInfo overwrites the first one, and subsequently, the intended login credentials are discarded.

     

    Thank you,

    Serban


    Serban Iliescu - MSFT
    Friday, December 18, 2009 4:22 PM
    Answerer

All replies

  • THis piece of code I have taken MSDN site and I have put required DLLs  in the c:\php\ext folder as instructed.

    http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx

    Rajib.
    Friday, December 18, 2009 6:16 AM
  • Hi Rajib,

     

    The code in MSDN includes a syntax error, but that error is in a section commented out. We should correct it anyway.

     

    I would like to draw your attention to another issue in your code. All the connection options have to be specified within a single array:

    $connectionInfo = array("UID" => $uid, "PWD" => $pwd, “Database”=>”dbase”);

     

    As it is now, the second assignment to $connectionInfo overwrites the first one, and subsequently, the intended login credentials are discarded.

     

    Thank you,

    Serban


    Serban Iliescu - MSFT
    Friday, December 18, 2009 4:22 PM
    Answerer