What are the potential pitfalls of using mysql_connect in PHP for database connections?

Using `mysql_connect` in PHP for database connections is not recommended as it is deprecated as of PHP 5.5.0 and removed in PHP 7.0.0. It is advised to use MySQLi or PDO instead for improved security, performance, and support for newer MySQL features.

// Using MySQLi for database connection
$mysqli = new mysqli("localhost", "username", "password", "database_name");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Using PDO for database connection
try {
    $pdo = new PDO("mysql:host=localhost;dbname=database_name", "username", "password");
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    die("Connection failed: " . $e->getMessage());
}