• 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

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Laravel dosen't connect with Oracle

Is it possible to change the table name in the migration file-laravel

array_map triple dimensional array [duplicate]

CSV to PHP class properties

Applying programmatically a coupon to an Order in WooCommerce3

Unable to match results of php hash_hmac() and coldfusion hmac()

How to set dynamic `home` and `siteurl` in WordPress?

Coinpayments create_transaction "ERROR: Invalid command!"

PHP: How to raise number to (tiny) fractional exponent?

Correctly determine if date string is a valid date in that format

PHP 8.1: strftime() is deprecated

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

Whats the point of running Laravel with the command 'php artisan serve'?

Install mysql client in docker image

About Contact Privacy policy Terms and conditions