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.

An example connection a MySQL database called a "test" with PDO

$username "root";
$password "";

try {
$conn = new PDO("mysql:host=$servername; dbname=test"$username$password);
// set the PDO error mode to exception
"Database TEST successfully connected"
PDOException $e)
"Connection failed: " $e->getMessage();