What are the potential pitfalls of using outdated PHP functions like mysql_connect in a project?

Using outdated PHP functions like mysql_connect can pose security risks as these functions are deprecated and no longer supported in newer PHP versions. It is recommended to switch to newer, more secure alternatives like PDO or MySQLi to ensure the safety and stability of your project.

// Using PDO to connect to a MySQL database
$host = 'localhost';
$dbname = 'database_name';
$username = 'username';
$password = 'password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    echo "Connected successfully";
} catch (PDOException $e) {
    die("Connection failed: " . $e->getMessage());
}