Brinkster Knowledge Base

KB Home   /  Support  /  Database  /  MS SQL  /   How do I connect to a MS SQL database with PHP
How do I connect to a MS SQL database with PHP Articles
Important information regarding the following code samples.

All references to "UserName" need to be replaced with your actual Brinkster UserName.
All references to "Password" need to be replaced with your actual Brinkster Password.


Microsoft SQL Database

Important information regarding the SQL Server Database code sample.

The following server name reference is not specific: SQL.Brinkster.com
Please log into your account, select the web site settings, and use the SQL Server database name listed there.


DSN-Less

<?

$dbhost = "premsqlxx.brinkster.com";

$dbname_and_username = "Brinkster_UserName";

$dbpwd = "Brinkster_Password";

 

$conn = new COM('ADODB.Connection');

$conn->Open("DRIVER={SQL Server}; SERVER=" . $dbhost . ";DATABASE=" . $dbname_and_username . ";UID=" . $dbname_and_username . ";PWD=" . $dbpwd . ";");

 

echo "<center><br><br>The MS SQL connection has been opened.<br><br>";

$conn->close;

echo "The MS SQL connection has been closed.</center>";

?>



DSN

$conn=odbc_connect('UserName','UserName',Password');