• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Using PHP to connect to a remote MSSQL database

phpsql-serverremote-access


PHP Snippet 1:

       $server = '11.22.33.44';
      // Connect to MSSQL
      $link = mssql_connect($server, 'db_username', 'db_password');

PHP Snippet 2:

$username ="WRITEUSER";
$password = "WRITEPASS";
$database = "WRITEDB";
$server = "WRITESERVERIP";

$connection = mssql_connect($server, $username, $password);
if (!$connection) {  die('Not connected : ' . mssql_get_last_message());} 


$db_selected = mssql_select_db($databaseb, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mssql_get_last_message());
} else{

    // Success
}

Related Snippets

How to get the ID of the link in another page in php

Log a user out of a website when they put their computer to sleep

Calculating Median of an array in PHP

Performance of foreach, array_map with lambda and array_map with static function

How to create a video stream from a single dynamic image in PHP

Laravel query builder binding parameters more than once

Laravel lang slug in url

How to redirect to another page and call a Function there on Angular ng-click

PHP: Print caught exception like Xdebug

PHP/HTML: Creating A SubMenu

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Xdebug can't connect back to Docker host

How to modify CSS in a specific page of the WP admin dashboard (backend)

How to downgrade or install a specific version of Composer?

Split a string array into pieces

About Contact Privacy policy Terms and conditions