<?php
$server_name = 'MY-PC';

$connect_info = array(
  'Database' => 'database_name',
  'UID' => 'username',
  'PWD' => 'password'
);

$connection = sqlsrv_connect($server_name, $connect_info);

if ($connection)
{
  echo 'Connection established.' . PHP_EOL;
}
else
{
  echo 'Connection could not be established.' . PHP_EOL;
  die(print_r(sqlsrv_errors()));
}
Published in: PHP
Download

Related snippets