What are the consequences of directly passing mysqli_query results to mysqli_fetch functions in PHP?

Directly passing mysqli_query results to mysqli_fetch functions in PHP can lead to errors or unexpected behavior because mysqli_query returns a result object, not a result set. To solve this issue, you should first store the result of mysqli_query in a variable and then pass that variable to mysqli_fetch functions.

// Incorrect way
$result = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM table"));

// Correct way
$query = mysqli_query($conn, "SELECT * FROM table");
$result = mysqli_fetch_assoc($query);