Cómo conectar la base de datos MySQL con sitios web de PHP

<?php
try{
    $sname = "localhost"; //just leave it as is 
    $uname = "test_name"; //the username 
    $password = "*************"; //the password

    $db_name = "test_db"; //the name of the db

    $conn = mysqli_connect($sname, $uname, $password, $db_name); //the connection
} catch(\Exception $e){
    echo "activate your mySQL and add the user_db with all the values\n";
    exit();
}
?>
MuffinCat