locked
Connecting from PHP fails' .cshtml works RRS feed

  • Question

  • Hey all,

      I've got a Azure Web Site setup for .NET 4.5 and PHP 5.3 (basically the defaults).

    I have a SQL Azure database. 

    I get the connection strings for both PHP and ADO.NET from the SQL Azure management page.

    The ADO.NET works just fine from a .cshtml page.

    phpinfo() shows the sqlsrv extension loaded yet the PHP app can't connect.

    It get the error:

    Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][SQL Server Native Client 11.0]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [message] => [Microsoft][SQL Server Native Client 11.0]SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => -1 [code] => -1 [2] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

    The PHP code is:

        $connectionInfo = array("UID" => "<myid>@<myserver>", 
                                "pwd" => "<password>", 
                                "Database" => "NetMeetv1", 
                                "LoginTimeout" => 10, 
                                "Encrypt" => 1);
        $serverName = "tcp:<myserver>.database.windows.net,1433";
        $conn = sqlsrv_connect($serverName, $connectionInfo);
        
        if($conn === false)
        {
            die(print_r(sqlsrv_errors(), true));
        }    
        
        return $conn;    


    Any ideas? I'm stumped. 

    ----- Ed

    Thursday, May 23, 2013 8:27 PM

Answers