Bonjour je rencontre un problème lors du requête
EDIT : UNION EN DOUBLON
voici le message d'erreur:
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe près de '' à la ligne 9 in D:\wamp64\www\teambet\models\BetModel.php on line 10
( ! ) PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe près de '' à la ligne 9 in D:\wamp64\www#\models\BetModel.php on line 10
Ma requête ("Fonctionne dans phpmyadmin")
Voici le code avec la boucle :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <?php function lastBetsClosed() { $db = dbConnect(); $req = $db->query('SELECT user_id ,event,null AS event_1,null AS event_2,null AS event_3,null AS event_4,sport,null AS sport_1,null AS sport_2,null AS sport_3,null AS sport_4,date_event,null AS date_event_1,null AS date_event_2,null AS date_event_3,null AS date_event_4,hour_event,null AS hour_event_1,null AS hour_event_2,null AS hour_event_3,null AS hour_event_4,type,cost,null AS cost_1,null AS cost_2,null AS cost_3,null AS cost_4,stake,prognosis,null AS prognosis_1,null AS prognosis_2,null AS prognosis_3,null AS prognosis_4,competition,null AS competition_1,null AS competition_2,null AS competition_3,null as competition_4,result FROM bet_simple UNION SELECT user_id,null AS event,event_1,event_2,event_3,event_4,null AS sport,sport_1,sport_2,sport_3,sport_4,null AS date_event,date_event_1,date_event_2,date_event_3,date_event_4,null AS hour_event,hour_event_1,hour_event_2,hour_event_3,hour_event_4,type,cost,cost_1,cost_2,cost_3,cost_4,stake,null AS prognosis,prognosis_1,prognosis_2,prognosis_3,prognosis_4,null as competition,competition_1,competition_2,competition_3,competition_4,result FROM bet_combi UNION '); return $req; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
40
41
42
43
44 <?php while ($data = $bets->fetch()) { ?> <tr> <td> <?= getUsername($data['user_id']); ?> </td> <td> <?= getIconSport($data['sport'], $data['type']); ?> </td> <td> <?= $data['event'] ?> </td> <td> <?= $data['date_event'] ?> </td> <td> <?= $data['prognosis'] ?> </td> <td> <?= $data['cost'] ?> </td> <td> </td> <td> <?php getGainBet($data['stake'], $data['cost'], $data['result']); ?> </td> <td> <?php getIconResult($data['result']); ?> </td> </tr> <?php } $bets->closeCursor(); ?>
Partager