• 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

Show only featured products in Woocommerce shop page

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

Is there a way to use Foundry Model for Authentification inside Functional Tests?

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

Wordpress add responsive srcset header image to theme

How to make a array inside array?

PHP: PDO + CSV export not downloading (headers issue?)

Send POST data via raw JSON with Postman

Laravel implode array items to new lines

Render the content of default_filter.php in Joomla front-end

How to change 'users' auth table and use another instead Laravel

How Can I Do LIMIT 1, 2 In WP_Query

Custom API and cunsuming in php?

insert multiple rows in a saveall in cakephp

Android Volley getParams() method not getting called for JsonObjectRequest

About Contact Privacy policy Terms and conditions