Insertion des données dans phpmyadmin
OdetteEmilie
Messages postés
6
Statut
Membre
-
Konseil Messages postés 641 Date d'inscription Statut Membre Dernière intervention -
Konseil Messages postés 641 Date d'inscription Statut Membre Dernière intervention -
Bonjour!
code formulaire
erreur apre execution
S'il vous plait repondez vite
code formulaire
<h2>Demande d'Habilitation</h2>
<form action="dbhabitation.php" method="post">
<label>Matricule
<input type="text" name="MATRICULE_USER">
</label><br/><br/>
<label>Nom
<input type="text" name="NOM_USER">
</label><br/><br/>
<label>Prenom
<input type="text" name="PRENOM_USER">
</label><br/><br/>
<label>Fonction
<input type="text" name="FONCTION_USER">
</label><br/><br/>
<label>Service
<input type="text" name="SERVICE_USER">
</label><br/><br/>
<label>Agence
<input type="text" name="AGENCE_USER">
</label><br/><br/>
<label>Nom de la Caisse
<input type="text" name="NOM_CAISSE_USER">
</label><br/><br/>
<input type="submit" value="Envoyer" >
</form>
<footer>
<p>Copyrigth 2020 Odette Emiie Felemou - Tout droit réserve</p>
</footer>
</body>
</[/html/htmlintro.php3 html]>
code database
<?[/php/phpintro.php3 php]
session_start();
$mat=$_POST['MATRICULE_USER'];
$nom=$_POST['NOM_USER'];
$prenom=$_POST['PRENOM_USER'];
$fonction=$_POST['FONCTION_USER'];
$serv=$_POST['SERVICE_USER'];
$agen=$_POST['AGENCE_USER'];
$caisse=$_POST['NOM_CAISSE_USER'];
$type=$_POST['NOM_CAISSE_USER'];
try {
$connexion=new PDO('mysql:host=[/internet/ip.php3 127.0.0.1];dbname=habilitation','[/contents/646-linux-gestion-des-utilisateurs root]','');
$connexion->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
$insert=$connexion->prepare("INSERT INTO utilisateur(,MATRICULE_USER,NOM_USER,PRENOM_USER,FONCTION_USER,SERVICE_USER,AGENCE_USER,NOM_CAISSE_USER) VALUES(?,?,?,?,?,?,?)");
$insert->execute(array($mat,$nom,$prenom,$fonction,$serv,$agen,$caisse));
} catch (PDOException $e) {
echo'error'.$e->getMessage();
}
?>
erreur apre execution
errorSQLSTATE[42000]: Syntax error or access violation: 1064 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 'MATRICULE_USER,NOM_USER,PRENOM_USER,FONCTION_USER,SERVICE_USER,AGENCE_USER,NOM_C' at line 1
?>
S'il vous plait repondez vite
EDIT : Ajout des balises de code (encore..... )
2 réponses
-
Bonjour,
Premièrement... merci de poster tes codes CORRECTEMENT sur le forum.
Pour ça il faut utiliser les balises de code.
Explications disponibles ici : https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
Ensuite, vu le message d'erreur.... la réponse devrait te sauter aux yeux !
Elle concerne ta requête... donc$insert=$connexion->prepare("INSERT INTO utilisateur(,MATRICULE_USER,NOM_USER,PRENOM_USER,FONCTION_USER,SERVICE_USER,AGENCE_USER,NOM_CAISSE_USER) VALUES(?,?,?,?,?,?,?)"); $insert->execute(array($mat,$nom,$prenom,$fonction,$serv,$agen,$caisse));
Si tu regardes bien... il semble que tu aies une virgule en trop avant "MATRICULE" ... non ??
-
Et au passage... qu'en est -il de ta précédente question ?
https://forums.commentcamarche.net/forum/affich-35690823-insertion-des-donnees-dans-la-base
.
-
-
ligne 52:
$insert=$connexion->prepare("INSERT INTO utilisateur(,MATRICULE_USER,NOM_USER,PRENOM_USER,FONCTION_USER,SERVICE_USER,AGENCE_USER,NOM_CAISSE_USER) VALUES(?,?,?,?,?,?,?)");
Commence par enlever la virgule juste après la parenthèse.
INSERT INTO utilisateur(,MATRICULE_USER