What potential issues can arise from using the deprecated mysql_* functions in PHP and what alternatives should be considered?

Using deprecated mysql_* functions in PHP can lead to security vulnerabilities, as these functions are no longer maintained and may contain security flaws. It is recommended to switch to the mysqli or PDO extensions, which offer more secure and modern ways to interact with databases in PHP.

// Using mysqli extension as an alternative to deprecated mysql_* functions
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

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

// Perform a query
$sql = "SELECT * FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["name"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();