1and1 Help Centre Categories

print article

Connect to an MSSQL Database Using PHP

For Microsoft packages using PHP and MSSQL. If you have a Linux package, please reference the MySQL Page instead.

You may occasionally need to use a PHP script to make changes to a MSSQL 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 MSSQL database.

$serverName = "db398617167.db.1and1.com";
$username = "dbo123456789";
$password = "yourPassword";
$database = "db123456789";
$connectionInfo = array( "UID"=>$username, "PWD"=>$password, "Database"=>$database);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
Please note:
The sample data needs to be replaced by your own.