1<?php
2$servername = "localhost";
3$username = "username";
4$password = "password";
5$dbname = "myDB";
6
7// Create connection
8$conn= mysqli_connect($servername,$username,$password,$dbname);
9// Check connection
10if (!$conn) {
11 die("Connection failed: " . mysqli_connect_error());
12}
13echo "Connected Successfully.";
14?>
1
2<?php
3$serverName = "serverName\\sqlexpress"; //serverName\instanceName
4
5// Since UID and PWD are not specified in the $connectionInfo array,
6// The connection will be attempted using Windows Authentication.
7$connectionInfo = array( "Database"=>"dbName");
8$conn = sqlsrv_connect( $serverName, $connectionInfo);
9
10if( $conn ) {
11 echo "Connection established.<br />";
12}else{
13 echo "Connection could not be established.<br />";
14 die( print_r( sqlsrv_errors(), true));
15}
16?>
17
18