This question already has an answer here:
I've got a warning in mysqli_free_result and wasn't able to solve it by myself. I have an android application that connects with the database through the webservice. When I test it in localhost it works fine, but when i try to run in my webhost (hostgator) i get this warning. All the things i find related to this warning are because the query wasn't Insert or Select type, but mine is. Please take a look at the code.
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/loupp759/public_html/AppBackEnd/dbmanager.php on line 54 {"result":"false","message":"You are Unregisterd.Try to input correct Information"}
function login($username){
$con = connectDB();
$query = "select id, nome, username, grupo from Participantes where username = '$username';";
$res = mysqli_query($con, $query);
$response = array();
$response['result'] = 'false';
$response['message'] = 'You are Unregisterd.'
. 'Try to input correct Information';
if( $res == FALSE ){
}else{
$num = mysqli_num_rows($res);
if($num > 0 ){
$row = mysqli_fetch_row($res);
$response['result'] = 'true';
$data = array();
$data['id'] = $row[0];
$data['name'] = $row[1];
$data['username'] = $row[2];
$data['group'] = $row[3];
$response['message'] = $data;
}
}
mysqli_free_result($res); <-------- this is the line of the error
mysqli_close($con);
return json_encode($response);
}
Thank you all
</div>
First correct your query
$query = "select id, name, username, group from Participantes where username = '$username'";
and match the name of fields with your responses