IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Problème requête SQL [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 48
    Points : 37
    Points
    37
    Par défaut Problème requête SQL
    Bonjour,

    j'ai saisi dans un fichier index.php le code suivant (il est volontairement tronqué avant et aprés par soucis de rapidité et de clarté)

    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    <table border="1" bgcolor=yellow>
    <caption><font face=verdana size=2><b>Données relatives à l'individu</b></font></caption>
    <tr>
    <td width=90>
    <font face=verdana size=1>Type Action</font>
    </td>
    <td width=90>
    <input type="listbox" name="type_action" value="type action"size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>Heure</font>
    </td>
    <td width=90>
    <input type="text" name="heure" value="heure" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>Sexe</font>
    </td>
    <td width=90>
    <input type="listbox" name="sexe" value="sexe" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>Age</font>
    </td>
    <td width=90>
    <input type="text" name="age" value="age" size="2">
    </tr>
    <tr>
    <td>
    <font face=verdana size=1>Numero bague</font>
    </td>
    <td>
    <input type="texte" name="num_bague" value="num_bague" size="10">
    </td>
    <td>
    <font face=verdana size=1>CS</font>
    </td>
    <td>
    <input type="listbox" name="CS" value="CS" size="10">
    </td>
    <td>
    <font face=verdana size=1>PC</font>
    </td>
    <td>
    <input type="checkbox" name="PC">
    </td>
    <td>
    <font face=verdana size=1>PI</font>
    </td>
    <td>
    <input type="checkbox" name="PI">
    </td>
    </tr>
    <tr>
    <td width=90>
    <font face=verdana size=1>NF</font>
    </td>
    <td width=90>
    <input type="text" name="NF" value="NF" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>PA</font>
    </td>
    <td width=90>
    <input type="text" name="PA" value="PA" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>CA</font>
    </td>
    <td width=90>
    <input type="text" name="CA" value="CA" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>Condition reprise</font>
    </td>
    <td width=90>
    <input type="text" name="Cond_repr" value="Cond_repr" size="2">
    </tr>
    <tr>
    <td width=90>
    <font face=verdana size=1>Circonstances reprise</font>
    </td>
    <td width=90>
    <input type="text" name="Circ_repr" value="Circ_repr" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>AS</font>
    </td>
    <td width=90>
    <input type="text" name="AS" value="AS" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>CR</font>
    </td>
    <td width=90>
    <input type="listbox" name="CR" value="CR" size="10">
    </td>
    <td width=90>
    <font face=verdana size=1>FM</font>
    </td>
    <td width=90>
    <input type="text" name="FM" value="FM" size="2">
    </tr>
    <tr>
    <td width=90>
    <font face=verdana size=1>FR</font>
    </td>
    <td width=90>
    <input type="text" name="FR"  value="FR" size="10">
    </td>
    <td>
    <font face=verdana size=1>Mémo</font>
    </td>
    <td colspan=5>
    <input type="textbox" name="Mémo" value="Mémo" size="75">
    </td>
    <TR>
    <td colspan="8">
    <center><input type="button" value="Nouvelle donnée individu" OnClick="javascript:RAS(23);javascript:RAS(24);
    javascript:RAS(25);javascript:RAS(26);javascript:RAS(27);javascript:RAS(28);javascript:RAS(29);javascript:RAS(30);
    javascript:RAS(31);javascript:RAS(32);javascript:RAS(33);javascript:RAS(34);javascript:RAS(35);javascript:RAS(36);
    javascript:RAS(37);javascript:RAS(38);javascript:RAS(39);javascript:RAS(40);"></center>
    </td>
    </TR>
    </tr>
    </table>

    Dans un second temps, je cherche à executer la requete suivante stockée dans mon fichier : add.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    $db = mysql_connect('localhost', 'root', '')  or die('Erreur de connexion '.mysql_error());
     
     
        mysql_select_db('bd_bagage',$db)  or die('Erreur de selection '.mysql_error()); 
     
    $sql = "INSERT INTO individu(ID_type_action,Sexe,Age,Bague,CS,Heure,NF,PA,CA,Memo,Cond_repr,Circ_repr,AS,FM,FR,ID_station) VALUES('$type_action','$sexe','$age','$num_bague','$CS','$heure','$PC','$PA','$CA','$Mémo','$Cond_repr','$Circ_repr','$AS','$FM','$FR','$ID_station')"; 
    	mysql_query($sql) or die('Erreur SQL !'.$sql.'<br><br>'.mysql_error());
     
    echo '<center><b>La donnée à été correctement ajoutée à la base.</b></center>'; 
    	echo'<center><form><input type="button" value="Retour" OnClick="javascript:history.back()"></form></center>';
        mysql_close();  // on ferme la connexion
    (la variable $ID_action etant une variable recupérée d'un identifiant automatique un peu plus haut dans la partie tronquée du code)

    Cependant : à l'execution de la requete : voici le message d'erreur :

    Erreur SQL !INSERT INTO individu(ID_type_action,Sexe,Age,Bague,CS,Heure,NF,PA,CA,Memo,Cond_repr,Circ_repr,AS,FM,FR,ID_station) VALUES('type action','sexe','age','num_bague','CS','heure','','PA','CA','Mémo','Cond_repr','Circ_repr','AS','FM','FR','')

    Erreur de syntaxe près de 'AS,FM,FR,ID_station) VALUES('type action','sexe','age','num_bagu' à la ligne 1

    Je désèspère à trouver la partie du code qui pose problème

  2. #2
    Membre habitué Avatar de Shinji62
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    135
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 135
    Points : 150
    Points
    150
    Par défaut
    Deja evite d' utiliser AS comme ca, essaye plutot `AS`.

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 48
    Points : 37
    Points
    37
    Par défaut
    merci beaucoup , il semble qu'il s'agissait effectivement bien du champ AS qui posait problème....
    Je suppose qu'il devait etre reconnu comme un instruction plutot d'un champ non ?

  4. #4
    Membre habitué Avatar de Shinji62
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    135
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 135
    Points : 150
    Points
    150
    Par défaut
    Exactement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème requête SQL
    Par mandaillou dans le forum Langage SQL
    Réponses: 15
    Dernier message: 03/10/2005, 11h37
  2. Problème requête SQL dans page ASP
    Par rocs dans le forum ASP
    Réponses: 14
    Dernier message: 26/07/2005, 15h38
  3. problème requête sql
    Par psychoBob dans le forum Langage SQL
    Réponses: 1
    Dernier message: 10/07/2005, 17h50
  4. problème requête sql
    Par perfectdams dans le forum Requêtes et SQL.
    Réponses: 5
    Dernier message: 21/06/2005, 18h09
  5. Réponses: 8
    Dernier message: 23/10/2003, 16h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo