Add additional check to prevent mysqli_result error