What are the potential pitfalls of using the mysql_ functions in PHP?

The potential pitfalls of using the mysql_ functions in PHP include security vulnerabilities such as SQL injection attacks, lack of support for newer MySQL features, and deprecated status in newer PHP versions. To solve these issues, it is recommended to use mysqli or PDO (PHP Data Objects) extensions which provide prepared statements to prevent SQL injection, support for newer MySQL features, and are more secure and reliable.

// Using mysqli extension to connect to 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);
}