What are the potential issues with using the mysql_db_query function in PHP for database operations?

Using the mysql_db_query function in PHP is not recommended as it is deprecated and may lead to security vulnerabilities such as SQL injection attacks. It is better to use parameterized queries with prepared statements to prevent these issues.

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

// Prepare a SQL query using prepared statements
$query = $mysqli->prepare("SELECT * FROM users WHERE username = ?");
$username = "example_user";
$query->bind_param("s", $username);
$query->execute();

// Fetch the results
$result = $query->get_result();
while ($row = $result->fetch_assoc()) {
    // Process the results
}

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