bonjour me voici une fois de plus avec un petit problème (je pense)
j'ai crée un formulaire avec des listes déroulante dedans qui affiche des donnée de la bdd (MySQL) et lors de la validation de mes information je recupère les donnée du formulaire dans un code Php qui effectue l'INSERT. mais une erreur s'affiche voici l'erreur:
et voici le code de mon formulaire:ErreurYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ONEFIT'','Mr','SELECT CODE FROM CODIFICATION WHERE LIBELLE='Mr'','stagiaire','em' at line 3 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ONEFIT'','Mr','SELECT CODE FROM CODIFICATION WHERE LIBELLE='Mr'','stagiaire','em' at line 3
Code html : 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 <!--------- FORMULAIRE EMPLOYE -------------> <div class="formulaire" id="d2"> <form method="post" action="ajout_personne.php"> <table id="table"> <tr align="center" height="20"> <td width="160"><p>Nom :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Nom_p" /><font size="1"></font></p></td> <td width="160"><p>Prénom :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Prenom_p" /><font size="1"></font></p></td> </tr> <tr align="center" height="20"> <td width="160"><p>Login :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Login_p" /><font size="1"></font></p></td> <td width="160"><p>Mot de passe :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Mdp_p" /><font size="1"></font></p></td> </tr> <!-- liste déroulante pour la sélection de la civilité --> <tr align="center" height="20"> <td width="160"><p>Civilité :<font size="1"></font></p></td> <!-- début du code pour la liste déroulante --> <td width="160"><p> <?php $reponse=mysql_query("SELECT LIBELLE FROM CODIFICATION WHERE NATURE = 'civilite'"); // requete sur la bdd pour recupérer les libelle de civilite (Mr,Mme...) echo"<select name='Civilite_p'>"; while ($donnees = mysql_fetch_array($reponse)) // création de la boucle sur le résultat de la requete effectuer avant. { // Cette boucle a pour bute de lister toute les valeures reçu via la requete sous forme de liste echo"<option value='".$donnees ['LIBELLE']."'>".$donnees['LIBELLE']."</option>"; //on donne le nom du libelle en valeur et on affiche celui ci grace a la boucle } echo"</select>"; ?> <font size="1"></font></p></td> <!-- fin du code de la liste déroulante + fin de la liste --> <td width="160"><p>fonction :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Fonction_p" /><font size="1"></font></p></td> </tr> <tr align="center" height="20"> <td width="160"><p>Groupe :<font size="1"></font></p></td> <td width="160"><p> <?php $reponse=mysql_query("SELECT LIBELLE FROM CODIFICATION WHERE NATURE = 'nature_groupe_personne'"); // requete sur la bdd pour recupérer les libelle des nature_groupe (r&h,production...) echo"<select name='Groupe_p'>"; while ($donnees = mysql_fetch_array($reponse)) // création de la boucle sur le résultat de la requete effectuer avant. { // Cette boucle a pour bute de lister toute les valeures reçu via la requete sous forme de liste echo"<option value='".$donnees ['LIBELLE']."'>".$donnees['LIBELLE']."</option>"; // on donne le nom du libelle en valeur et on affiche celui ci grace a la boucle } } echo"</select>"; ?> <font size="1"></font></p></td> <td width="160"><p>Etablissement :<font size="1"></font></p></td> <td width="160"><p> <select name="Etablissement_p"> <option value="ONEFIT"> ONEFIT </option> </select> <font size="1"></font></p></td> </tr> <tr align="center" height="20"> <td width="160"><p>téléphone fixe :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="TelFixe_p" /><font size="1"></font></p></td> <td width="160"><p>téléphone portable :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="TelPort_p" /><font size="1"></font></p></td> </tr> <tr align="center" height="20"> <td width="160"><p>Fax :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Fax_p" /><font size="1"></font></p></td> <td width="160"><p>E-mail :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Mail_p" /><font size="1"></font></p></td> </tr> <tr align="center" height="20"> <td width="160"><p>Date d'arrivée :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Darrivee_p" /><font size="1"></font></p></td> <td width="160"><p>Contrat :<font size="1"></font></p></td> <td width="160"><p><input type="text" name="Contrat_p" /><font size="1"></font></p></td> </tr> </table> <input type="submit" value="Création de la personne" /> </form> </div>
et le code de ma page php qui effectue l'insert:
je pense que je n'ai pas fais une grosse erreur mais je n'arrive pas a voir ou ça cloche. Je vous remercie d'avance
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 <?php //connexion Mysql $base="onefit"; $srv=mysql_connect('127.0.0.1','root',''); $bdd=mysql_select_db("$base"); // recupération des information saisi dans le formulaire $nom=$_POST['Nom_p']; $prenom=$_POST['Prenom_p']; $login=$_POST['Login_p']; $mdp=$_POST['Mdp_p']; $civilite=$_POST['Civilite_p']; // liste a regarder $fonction=$_POST['Fonction_p']; $groupe=$_POST['Groupe_p']; // liste a regarder $etablissement=$_POST['Etablissement_p']; // liste a regarder $tel_fix=$_POST['TelFixe_p']; $tel_port=$_POST['TelPort_p']; $fax=$_POST['Fax_p']; $mail=$_POST['Mail_p']; $date_arr=$_POST['Darrivee_p']; $contrat=$_POST['Contrat_p']; $code_etab="SELECT CODE FROM CODIFICATION WHERE LIBELLE='".$etablissement."'"; $code_civ="SELECT CODE FROM CODIFICATION WHERE LIBELLE='".$civilite."'"; $code_statut="SELECT CODE FROM CODIFICATION WHERE LIBELLE='enploye'"; $code_groupe="SELECT CODE FROM CODIFICATION WHERE LIBELLE='".$groupe."'"; $date_enregistre= date("Y-m-d"); $req2 = "INSERT INTO PERSONNE (num_Personne,num_etablissement,nature_civilite,code_civilite,fonction_personne,nature_statut,code_statut,nature_groupe,code_groupe, nom,prenom,telFix,telPort,fax,mail,type_contrat,date_arrivee,date_depart,login,mdp,date_enregistrement,com) VALUES('','$code_etab','$civilite','$code_civ','$fonction','employe','$code_statut','$groupe','$code_groupe','$nom', '$prenom','$tel_fix','$tel_port','$fax','$mail','$contrat','$date_arr,'','$login','$mdp',$date_enregistre,'')"; $resultat2= mysql_query($req2) or die ('Erreur'.mysql_error().' : '.mysql_error()); echo"<form method='post' action='creer_Codification.php'>"; echo"<center>l'employer a bien été crée <br/>"; echo"<input type='submit' value='OK' />"; echo"</center></form>"; ?>![]()
Partager