how to establish sql connection in php code example
Example 1: php sql connection
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn= mysqli_connect($servername,$username,$password,$dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected Successfully.";
?>
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();
}
?>