This error usually indicates that you are attempting to use the mysqli_free_result() function to free an invalid result set object. This could be because you are trying to free a result set that has already been freed, or because you are trying to free something that is not a result set object.
To resolve this issue, ensure that you are passing a valid result set object to the mysqli_free_result() function. You can use the mysqli_query() function to execute an SQL query, which returns a result set object. Make sure you are passing this object to the mysqli_free_result() function.
Additionally, if you are using the `mysqli_multiQuery()` function to execute multiple SQL queries, you need to release each result set after using it. You can use the `mysqli_more_results()` and `mysqli_next_result()` functions to check whether there are additional result sets, and then use the `mysqli_free_result()` function within a loop to release them. For example:
// 执行 SQL 查询
$result = mysqli_query($conn, "SELECT * FROM mytable");
// 使用结果集
while ($row = mysqli_fetch_assoc($result)) {
// 处理每行数据
}
// 释放结果集
mysqli_free_result($result);// 执行多个 SQL 查询
if (mysqli_multi_query($conn, "SELECT * FROM mytable1; SELECT * FROM mytable2;")) {
do {
// 获取当前结果集
$result = mysqli_store_result($conn);
if ($result) {
// 使用结果集
while ($row = mysqli_fetch_assoc($result)) {
// 处理每行数据
}
// 释放结果集
mysqli_free_result($result);
}
} while (mysqli_more_results($conn) && mysqli_next_result($conn));
}If you still encounter issues, please check your code and ensure that you are using the mysqli_free_result() function correctly. If the problem persists, consider enabling exception handling when establishing the connection and use the mysqli_report() function to obtain more detailed information.