This is the error code i recieve
fatal error: call to a member function fetch_assoc() on a non-object in
This code works fine on my localhost but when i go live with it i get the above error. I am guessing its within the $query but I can not pin point it
public function getDraftPlayers() {
$query = "SELECT p.id as id, CONCAT(p.fname, ' ', p.lname) as name, t.id as team_id, t.name as team_name, p.position as position, count(1) as games_played, sum(ps.goals) as goals, sum(ps.assists) as assists, sum(ps.minutes) as minutes, p.draftround as draftround FROM players p JOIN teams t ON p.draftteam = t.id LEFT OUTER JOIN player_stats ps ON ps.playerid=p.id WHERE p.draftround > 0 AND p.draftseason = " . $this->season_id . " GROUP BY p.id ORDER BY draftround ASC, draftposition ASC";
$result = $this->mysqli->query($query);
while ($row = $result->fetch_assoc()) { [COLOR="#FF0000"]<--this is the line that give the error[/COLOR]
$draft_players[$row['draftround']][] = $row;
}
$result->free();
return $draft_players;
}
i have also tried the below. I get the page to load but no results
if( ! $result ){
} else {
while ($row = $result->fetch_assoc()) {
$draft_players[$row['draftround']][] = $row;
}
}