What are the potential pitfalls of using the mysql_* functions in PHP, and what alternative solutions are recommended?

The mysql_* functions in PHP are deprecated and have been removed as of PHP 7.0 due to security vulnerabilities and lack of prepared statement support, making them prone to SQL injection attacks. It is recommended to use MySQLi (MySQL Improved) or PDO (PHP Data Objects) extensions for database operations in PHP as they provide better security and performance.

// Using MySQLi extension
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Perform a query using prepared statement
$stmt = $mysqli->prepare("SELECT * FROM table WHERE column = ?");
$stmt->bind_param("s", $value);
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    // Process data
}

$stmt->close();
$mysqli->close();