What are the potential risks of using the mysql_* extension in PHP for querying data from a database?

Using the mysql_* extension in PHP for querying data from a database poses security risks due to its deprecated status and lack of support for modern features. To mitigate these risks, it is recommended to switch to MySQLi or PDO extensions, which offer better security, performance, and support for prepared statements to prevent SQL injection attacks.

// 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);
}