Bonjour,
Je me permets de demander de l'aide concernant l'erreur suivante :Tip : La ligne 37 correspond à : $utilisateur->setIdIntervenant(IntervenantDAO::maxID()+1); dans le controleurInscription().Fatal error: Uncaught Error: Unsupported operand types in C:\wamp64\www\public_html\PPE 3.2\PPE3.2 - IFRA EN COURS\controleur\controleurInscription.php on line 37
Ci - dessous, vous trouverez les fichiers qui sont concernés (je suis le modèle MVC)
Le controleurInscription :
Mon intervenantDAO (pas en entier, juste les fonctions auxquelles je fais appel) qui me permet d'avoir accès aux traitements relatifs à la BDD :
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
45
46
47
48
49
50 <?php require_once 'fonctions/formulaire.php'; $formInscription = new Formulaire("post","index.php","formInscription","formInscription"); $formInscription->ajouterComposantLigne($formInscription->creerTitreH3("Créer un utilisateur")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerLabelFor("nom", "Nom : ")); $formInscription->ajouterComposantLigne($formInscription->creerInputTexte("nom", "nom", "", "" ,"" , "" , "")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerLabelFor("prenom", "Prénom : ")); $formInscription->ajouterComposantLigne($formInscription->creerInputTexte("prenom", "prenom", "", "" ,"" , "" , "")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerLabelFor("codeS", "Statut : ")); $formInscription->ajouterComposantLigne($formInscription->creerInputTexte("codeS", "codeS", "", "" ,"" , "" , "")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerLabelFor("nomUtilisateur", "Nom d'utilisateur : ")); $formInscription->ajouterComposantLigne($formInscription->creerInputTexte("nomUtilisateur", "nomUtilisateur", "", "" ,"" , "" , "")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerLabelFor("mdp", "mot de passe : ")); $formInscription->ajouterComposantLigne($formInscription->creerInputMdp("mdp", "mdp", "","","","","")); $formInscription->ajouterComposantTab(); $formInscription->ajouterComposantLigne($formInscription->creerInputSubmit("enregistrer", "enregistrer", "Enregistrer")); $formInscription->ajouterComposantTab(); $formInscription->creerFormulaire(); if(isset($_POST['enregistrer'])){ $utilisateur = new Intervenant(); $utilisateur->setIdIntervenant(IntervenantDAO::maxID()+1); $utilisateur->setLogin($_POST['nomUtilisateur']); $utilisateur->setMdp($_POST['mdp']); $utilisateur->setPrenomIntervenant($_POST['prenom']); $utilisateur->setNomIntervenant($_POST['nom']); $utilisateur->setCodeStatut($_POST['codeS']); IntervenantDAO::ajouterIntervenant($utilisateur); } require_once 'vue/vueInscription.php' ;
Et le fichier intervenant (DTO) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public static function maxID() { $sql = "select MAX(idIntervenant) from intervenant"; $req = dBConnex::getInstance()->prepare($sql); $req->execute(); return $req->fetch(); } public static function ajouterIntervenant(Intervenant $unIntervenant){ $sql = "insert into intervenant values (".$unIntervenant->getIdUtilisateur().",'".$unIntervenant->getCodeStatut()."','".$unIntervenant->getLogin()."','".$unIntervenant->getMdp()."','".$unIntervenant->getPrenomIntervenant()."','".$unIntervenant->getNomIntervenant()."')"; return DBConnex::getInstance()->exec($sql); }
J'aurais donc besoin d'aide pour pouvoir comprendre mon erreur.
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 <?php class Intervenant { use Hydrate; private $idIntervenant; private $login; private $mdp; private $codeStatut; private $nomIntervenant; private $prenomIntervenant; public function __construct($unId = NULL, $unLogin = NULL, $unmdp = NULL, $unstatut = NULL, $nomIntervenant = null, $prenomIntervenant = null){ $this->idIntervenant = $unId; $this->login = $unLogin; $this->codeStatut = $unstatut; $this->mdp = $unmdp; $this->nomIntervenant = $nomIntervenant; $this->prenomIntervenant = $prenomIntervenant; } public function getLogin() { return $this->login; } public function getMdp() { return $this->mdp; } public function getCodeStatut() { return $this->codeStatut; } public function setLogin($login) { $this->login = $login; } public function setMdp($mdp) { $this->mdp = $mdp; } public function setCodeStatut($codeStatut) { $this->codeStatut = $codeStatut; } public function getIdIntervenant() { return $this->idIntervenant; } public function setIdIntervenant($idIntervenant) { $this->idIntervenant = $idIntervenant; } public function getNomIntervenant() { return $this->nomIntervenant; } public function getPrenomIntervenant() { return $this->prenomIntervenant; } public function setNomIntervenant($nomIntervenant) { $this->nomIntervenant = $nomIntervenant; } public function setPrenomIntervenant($prenomIntervenant) { $this->prenomIntervenant = $prenomIntervenant; } }
De mon côté, j'ai essayé de récrire la requête avec des requêtes paramétrées (bindParam..) mais l'erreur persistait. Vu que l'erreur concerne seulement le type, je ne vois pas en quoi l'incrémentation de deux nombres causes un soucis.. Mais vu que la fonction maxID() -> retourne un tableau contenant un entier, ça pourrait être le problème de type.
Merci !
Partager