Probleme mysql error in your SQL syntax;
Résolu
smile88
Messages postés
53
Date d'inscription
Statut
Membre
Dernière intervention
-
smile88 Messages postés 53 Date d'inscription Statut Membre Dernière intervention -
smile88 Messages postés 53 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
jai un probleme mysql quand jenvoi lé requete a ma base il m'affiche ce message d'erreur:
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 ''iga1'.'profil' ('ID_PROFIL', 'NOM_PROF', 'PROF_SALOME', 'PROF_MANTIS') VALU' at line 1
voici mon code php:
jai un probleme mysql quand jenvoi lé requete a ma base il m'affiche ce message d'erreur:
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 ''iga1'.'profil' ('ID_PROFIL', 'NOM_PROF', 'PROF_SALOME', 'PROF_MANTIS') VALU' at line 1
voici mon code php:
<?php
include('conf.php');
//récupération des valeurs des champs:
$nom = $_POST["nom"] ;
$s = $_POST["salome"];
$m = $_POST["mantis"];
//création de la requête SQL:
$sql = "INSERT INTO 'iga1'.'profil' ('ID_PROFIL', 'NOM_PROF', 'PROF_SALOME', 'PROF_MANTIS')
VALUES ( NULL,'$nom','$s','$m')" ;
$requete = mysql_query($sql) or die( mysql_error() ) ;
if($requete)
{echo "<script language='JavaScript'>alert('Profil ajouté avec succés')</script>";
}
else
{
echo"<script language='JavaScript'>alert('L ajout a échoué')</script>";
}
?>
2 réponses
-
Bonsoir,
Les caractères pour délimiter les noms de tables/champs doivent être des "backquotes" , mais tu peux aussi les omettre : tu as donc le choix entre$sql = "INSERT INTO iga1.profil ('ID_PROFIL', 'NOM_PROF', 'PROF_SALOME', 'PROF_MANTIS') VALUES ( NULL,'$nom','$s','$m')" ;
A+++ -
probleme resolu :)))))
il se fait que la requete soit:
$sql = "INSERT INTO iga1.profil (ID_PROFIL,NOM_PROF,PROF_SALOME, PROF_MANTIS)
VALUES ( NULL,'$nom','$s','$m')" ;