how to connect database in php to server SQL code example
Example 1: php connect ms sql server
<?php
$serverName = "serverName\\sqlexpress";
$connectionInfo = array( "Database"=>"dbName");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
Example 2: mysql connection phpmyadmin
<?php
echo "IT WORKS";
$con = mysqli_connect('localhost', 'root', 'root', 'unityaccess');
if(mysqli_connect_errno()) {
echo "1: Connection Failed";
exit();
}
?>