• 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

Find out the name of the last script that included the current one

how to get value from array in laravel

How to add a custom field to all Woocommerce attribute terms using add_action

Call to a member function fetch_field() on a non-object MySQLiDB

How can I get a div content in php

How to remove from a multidimensional array all duplicate elements including the original?

PHP Include for HTML?

Mobile browsers are adding .html to filename on download

How to submit a form when page loads using JavaScript?

advanced custom fields wordpress custom class

How to fix Call to undefined method AppModelsTableName::factory?

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Check for PDO Results, If None Display Message, If Yes then Loop Through

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

Xdebug in Laravel is not working with VSCode

About Contact Privacy policy Terms and conditions