Azure SQL and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Azure SQL and PHP

Post 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);
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Azure SQL and PHP

Post 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));
}
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Azure SQL and PHP

Post 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
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply