Select Category
Sitemap Help Contact
print article

Connecting to MS SQL databases using PHP

This article is intended for Microsoft packages using PHP and MS SQL. If you have a Linux package, you will want to reference the MySQL page instead.

You may occasionally need to use a PHP script to make changes to a MS SQL database instead of the more common ASP or ASP.NET scripts. Use the example below as reference when making your PHP connection script to a MS SQL database. Replace the text in quotes for the first four lines below with your database information.

$serverName = "";
$username = "dbo123456789";
$password = "yourPassword";
$database = "db123456789";
$connectionInfo = array( "UID"=>$username, "PWD"=>$password, "Database"=>$database);
$conn = sqlsrv_connect( $serverName, $connectionInfo);

For additional information, you may want to reference: