Page 1 of 1

Azure SQL and PHP

Posted: Sat Jan 25, 2014 2:38 pm
by Vegan
I have a database created for my web site, I was wondering what I need to massage the provided code into something useful

Code: Select all

Server: laadn2rtfm.database.windows.net,1433 \r\nSQL Database: hardcoregames\r\nUser Name: webmaster\r\n\r\nPHP Data Objects(PDO) Sample Code:\r\n\r\ntry {\r\n   $conn = new PDO ( \"sqlsrv:server = tcp:laadn2rtfm.database.windows.net,1433; Database = hardcoregames\", \"webmaster\", \"{your_password_here}\");\r\n    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );\r\n}\r\ncatch ( PDOException $e ) {\r\n   print( \"Error connecting to SQL Server.\" );\r\n   die(print_r($e));\r\n}\r\n\rSQL Server Extension Sample Code:\r\n\r\n$connectionInfo = array(\"UID\" => \"webmaster@laadn2rtfm\", \"pwd\" => \"{your_password_here}\", \"Database\" => \"hardcoregames\", \"LoginTimeout\" => 30, \"Encrypt\" => 1);\r\n$serverName = \"tcp:laadn2rtfm.database.windows.net,1433\";\r\n$conn = sqlsrv_connect($serverName, $connectionInfo);

Re: Azure SQL and PHP

Posted: Sat Jan 25, 2014 4:04 pm
by Celauran
Not sure what you mean. What goes wrong when you try this?

Code: Select all

try {
   $conn = new PDO ( "sqlsrv:server = tcp:laadn2rtfm.database.windows.net,1433; Database = hardcoregames", "webmaster", "{your_password_here}");
    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch ( PDOException $e ) {
   print( "Error connecting to SQL Server." );
   die(print_r($e));
}

Re: Azure SQL and PHP

Posted: Sat Jan 25, 2014 4:27 pm
by Vegan
The stupid formatting is not very tidy at all, makes it hard to be sure I snipped it out properly

The first part is just text, so much for PHP