What are the potential pitfalls of using the mysql_* functions in PHP for database connectivity?

Using the mysql_* functions in PHP for database connectivity is discouraged because they are deprecated and no longer maintained, making them vulnerable to security risks and compatibility issues with newer versions of PHP. To mitigate these risks, it is recommended to use mysqli or PDO extensions for interacting with databases in PHP.

// Using mysqli extension for connecting to a MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}