locked
[PHP] Using PHP based Web App to Access SQL database on Azure RRS feed

  • Question

  • Hi,

    I've been trying to use PHP to connect to an SQL Database that I created on Azure.

    The deployment option that I chose was to pull code from GitHub.

    If I write a simple "Hello world" in PHP, it works just fine. I can open up the browser and the print out is there. But when I try to connect to the database to pull data, I am running into problems.

    For example, I put in the code:

    <?php
    $serverName = "mynewxxxrxver20170523.database.windows.net";
    $connectionOptions = array("Database"=>"MySampleDatabase", "Uid"=>"I put in Username", "PWD"=>"I put in Password");
    $conn = sqlsrv_connect($serverName, $connectionOptions);
    if( $conn ) {
         echo "Connection established.<br />";
    }else{
         echo "Connection could not be established.<br />";
         die( print_r( sqlsrv_errors(), true));
    }

    ?>


    And I get the result on the browser:

    "MySampleDatabase", "Uid"=>"ServerAdmin", "PWD"=>"NTpxxd11!!"); $conn = sqlsrv_connect($serverName, $connectionOptions); if( $conn ) {echo "Connection established."; }else{ echo "Connection could not be established."; die(print_r (sqlsrv_errors(), true)); } ?> 

    I don't get it. For my App on Azure I select the PHP version 7.1 under application settings.



    Sunday, May 28, 2017 4:29 AM

All replies