Demande d'aide sur un type bool
david76-21
Messages postés
14
Statut
Membre
-
jordane45 Messages postés 40050 Statut Modérateur -
jordane45 Messages postés 40050 Statut Modérateur -
J'essaye de retourner la liste des ateliers dans un programme de séminaire en ligne cela marche tout s'affiche mais j'ai une erreur de type bool
Merci de votre aide
Notice: Trying to access array offset on value of type bool in /home/apache/wseminaire/www/model/ModelParticipant.php on line 51
Merci de votre aide
Notice: Trying to access array offset on value of type bool in /home/apache/wseminaire/www/model/ModelParticipant.php on line 51
<?php
include_once('src/db/connect.php');
class ModelParticipant {
private $connect;
public function __construct(){
// Récupération de la connexion à la bdd
$cnt = new connect;
$this->connect = $cnt->setConnection();
}
public function read(){
// Récupération des données événements
$info = array();
$nbr = array();
$req2 = $this->connect->query('SELECT id, name_ev, date_ev FROM event ORDER BY date_ev DESC');
$res = $this->connect->query('SELECT id, name_ev, date_ev FROM event ORDER BY date_ev DESC');
while ($data2 = $req2->fetch()) {
$id = $data2['id'];
// Réucpèrer le nombre de participants
$req3 = $this->connect->prepare('SELECT COUNT(id) AS nbr FROM participant WHERE id_event=:value');
$req3->bindParam(':value', $id, PDO::PARAM_INT);
$req3->execute();
array_push($nbr, $req3->fetch());
$req3->closeCursor();
}
$return = array("res" => $res, "info" => $info, "nbr" => $nbr);
return $return;
}
public function readDetail($id) {
$req = $this->connect->prepare('SELECT id, id_event, name, lastname, fonction, tel, mail, particip, dej, din, ateliers FROM participant WHERE id_event=:value');
$req->bindParam(':value', $id, PDO::PARAM_INT);
$req->execute();
$req1 = $this->connect->prepare('SELECT ateliers FROM participant WHERE id_event=:value');
$req1->bindParam(':value', $id, PDO::PARAM_INT);
$req1->execute();
$atelier = array();
$i = 0;
while ($data = $req1->fetch()){
$at = explode(',', $data['ateliers']);
$atelier[$i] = "";
foreach ($at as $key) {
$req2 = $this->connect->prepare('SELECT name_atelier FROM atelier where id=:value');
$req2->bindParam(':value', $key, PDO::PARAM_INT);
$req2->execute();
$nameAt = $req2->fetch();
$atelier[$i] .= $nameAt['name_atelier']."<br />";
}
$i++;
}
$res = $req;
return array("1" => $res, "2" => $atelier);
}
A voir également:
- Notice: trying to access array offset on value of type bool
- Notice gratuite - Guide
- Cannot access offset of type string on string - Forum PHP
- Montre mingrui notice - Forum Accessoires & objets connectés
- Input signal out of range ✓ - Forum Matériel & Système
- Qwerty to azerty - Guide
2 réponses
bonjour,
il me semble que tu négliges de vérifier si la requête a bien fonctionné.
il me semble que tu négliges de vérifier si la requête a bien fonctionné.
david76-21
Messages postés
14
Statut
Membre
Le résultat s'affiche bien donc la requête fonctionne mais j'ai cette erreur de type bool en entrée de page
yg_be
Messages postés
24281
Statut
Contributeur
1 584
>
david76-21
Messages postés
14
Statut
Membre
https://www.php.net/manual/fr/pdostatement.fetch.php