What potential pitfalls are involved in using the mysql_ extension in PHP for database operations?

Using the mysql_ extension in PHP for database operations can lead to security vulnerabilities due to its deprecated status and lack of support for modern features like prepared statements. To address this issue, it is recommended to switch to MySQLi or PDO extensions, which offer better security and functionality.

// Connect to the database using MySQLi extension
$mysqli = new mysqli("localhost", "username", "password", "database");

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