What are the potential pitfalls of mixing mysql_ and mysqli_ functions in a PHP script?

Mixing mysql_ and mysqli_ functions in a PHP script can lead to errors and inconsistencies in your database interactions. To avoid this issue, it's recommended to stick to one type of MySQL extension (either mysql_ or mysqli_) throughout your script.

// Example of using only mysqli_ functions in a PHP script

// Connect to the database using mysqli_
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Perform a query using mysqli_
$result = $mysqli->query("SELECT * FROM table");

// Fetch data using mysqli_
while ($row = $result->fetch_assoc()) {
    // Output data
    echo "Name: " . $row["name"] . "<br>";
}

// Close the connection
$mysqli->close();