function __construct(mysqli $db, $country = NULL, $sport = NULL) {
$this->db = $db;
$this->country = base64_decode($country);
$this->sport = base64_decode($sport);
}
public function GetColor($colorcode) {
$query = 'SELECT naam_nl FROM colors WHERE code = $colorcode';
$result = $this->db->query($query);
while ($row = $result->fetch_assoc()) { // Line 21
echo $row['naam_nl'];
}
$result->close();
}
Gives me:
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/cloud/public/td/teamdresser.class.php on line 21
So I tried:
$result = $this->db->query($query);
while ($row = $this->db->fetch_assoc($result)) {
echo $row['naam_nl'];
}
And then...
Fatal error: Call to undefined method mysqli::fetch_assoc() in /home/cloud/public/td/teamdresser.class.php on line 21
I'm doing something wrong.. Can someone point me in the right direction?