Sunday, April 13, 2014

Connect Remote MSSQL Server with PHP

Connect MSSQL Server with PHP

<?php
$server = 'xxx.xxx.xxx:port';
// Connect to MSSQL
$link = mssql_connect($server, 'user', 'password');
if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}
if($link)
{
    echo mssql_get_last_message();
    mssql_close();
}
?>

You can use localhost instead of ip or url if you are connecting on the same machine. :) Thanks :)