query geeft error on fetch_array.
ik zit met het volgende als ik deze query uitvoer.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public function getAllData($OrderBydate = '') {
$query = '
SELECT
google_users.oauth_uid,
google_users.portal_name,
swap_settings.id,
swap_settings.swap_value,
user_gold_sent.user_id,
user_gold_sent.swap_id,
user_gold_sent.gold_sent,
user_gold_sent.date,
SUM(user_gold_sent.gold_sent) AS total_gold,
COUNT(user_gold_sent.gold_sent) AS total_runs
FROM
google_users,
swap_settings,
user_gold_sent
WHERE
user_gold_sent.user_id = google_users.oauth_uid
AND
user_gold_sent.swap_id = "1"
GROUP BY
google_users.portal_name';
if($OrderBydate == '1') {
$query .= 'ORDER BY user_gold_sent.date ASC';
}
$run_query = $this->db->query($query);
$res = array();
while($record = $run_query->fetch_array()) {
$res[] = $record;
}
return $res;
}
$query = '
SELECT
google_users.oauth_uid,
google_users.portal_name,
swap_settings.id,
swap_settings.swap_value,
user_gold_sent.user_id,
user_gold_sent.swap_id,
user_gold_sent.gold_sent,
user_gold_sent.date,
SUM(user_gold_sent.gold_sent) AS total_gold,
COUNT(user_gold_sent.gold_sent) AS total_runs
FROM
google_users,
swap_settings,
user_gold_sent
WHERE
user_gold_sent.user_id = google_users.oauth_uid
AND
user_gold_sent.swap_id = "1"
GROUP BY
google_users.portal_name';
if($OrderBydate == '1') {
$query .= 'ORDER BY user_gold_sent.date ASC';
}
$run_query = $this->db->query($query);
$res = array();
while($record = $run_query->fetch_array()) {
$res[] = $record;
}
return $res;
}
Krijg ik een foutmelding
Fatal error: Uncaught Error: Call to a member function fetch_array() on boolean in
echter als ik de code uitvoer in phpmyadmin dan krijg ik wel de juiste resultaten.
als ik dan vervolgens $query .= 'ORDER BY user_gold_sent.date' weg haal dan geen foutmelding.
De functie roep ik zo op
Code (php)
1
2
3
2
3
foreach($GoldSwap->getAllData(1) as $row) {
echo '<td align="center" bgcolor="#3e3e3e">'.$row['gold_sent'].'</td><td align="center">'.$row['date'].'</td>';
}
echo '<td align="center" bgcolor="#3e3e3e">'.$row['gold_sent'].'</td><td align="center">'.$row['date'].'</td>';
}
Iemand die een ander licht er op kan schijnen.
Bijvoorbaat dank.
En dus een boolean (fals) opwerpt i.p.v een resource.
$query .= 'ORDER BY user_gold_sent.date ASC';
Moest zijn
$query .= ' ORDER BY user_gold_sent.date ASC';\
Let op de spatie na de ' en voor de ORDER BY zo klein kan het dus zijn. pff