There are more ways to connect to a MySQL database in PHP. PDO (PHP Data Objects) is the best of them.
Advantages of PDO is a consistent interface across many different types of database, uses an object-oriented approach, and supports more features offered by newer databases.
Using a PDO database connection recommends wherever possible.
$servername = "localhost";
$username = "root";
$password = "";
$conn = new PDO("mysql:host=$servername; dbname=test", $username, $password);
// set the PDO error mode to exception
echo "Database TEST successfully connected";
echo "Connection failed: " . $e->getMessage();