What are the potential issues with mixing mysqli and mysql functions in PHP code?

Mixing mysqli and mysql functions in PHP code can lead to compatibility issues as they are two different PHP extensions for interacting with MySQL databases. To avoid problems, it is recommended to stick to one extension throughout your codebase. If you are using mysqli, make sure to use mysqli functions consistently for database operations.

// Example of using only mysqli functions throughout the code
$mysqli = new mysqli("localhost", "username", "password", "database");

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

$query = "SELECT * FROM table";
$result = $mysqli->query($query);

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

$mysqli->close();