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 :

[SQL] Pb Mysql n'insert pas les bonnes valeur dans la bdd


Sujet :

PHP & Base de données

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 5
    Points : 2
    Points
    2
    Par défaut [SQL] Pb Mysql n'insert pas les bonnes valeur dans la bdd
    Bonjour a tous et à toutes !

    Je vous expose mon pb
    J'ai fait une petite bdd couple a un formulaire html pour gerer les adhérents de l'association dont je m'occupe. le probleme que je rencoutre est que lorsque je rempli le formulaire pour ajouter une nouvelle personne , dans la bdd je retrouve bien une nouvelle ligne mais qui contient les infos de mon premier adherent et non de la nouvelle personne.


    Voici le code de la page que j'utilise pour l'ajout dans la bdd :


    code html du formulaire:
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
     
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Gestion adhérents</title>
    </head>
    <body>
    <FORM METHOD="POST" ACTION="ajout_adh.php" >
    <BLOCKQUOTE>
    <TABLE cellpadding="0" cellspacing="0" width="579" id="table2">
    <TR>
    <TD ALIGN="left" rowspan="2">
    <p align="left"><b><i><u><font size="2">1. Date adhésion : (jj/mm/aa)</font></u></i></b><p>
    <em><font size="2">Jour : </font> </em><INPUT TYPE=TEXT NAME="jj" SIZE=2 MAXLENGTH=2><font size="2">
    </font>
     
    <em> <font size="2">Mois : </font> </em><i><INPUT TYPE=TEXT NAME="mm" SIZE=2 MAXLENGTH=2><font size="2">
    </font>
    </i>
    <em> <font size="2">Année : </font> </em><i><INPUT TYPE=TEXT NAME="aa" SIZE=4 MAXLENGTH=4><font size="2">
    </font>
    </i>
    </p>
    <b><i><u><font size="2">2. Login (p.nom)</font></u></i></b><p>
    <i>
    <INPUT TYPE=TEXT NAME="login" SIZE=40></i></p>
    <p align="left"><u><font size="2"><b><i>3</i></b></font></u><b><i><u><font size="2">. Coordonnées</font></u></i></b><p>
    <EM><font size="2">Nom :</font></EM></p>
    <i>
    <INPUT TYPE=TEXT NAME="nom" SIZE=40><font size="2"> </font>
    </i>
    <p>
    <em><font size="2">Prénom :</font></em></p>
    <i>
    <INPUT TYPE=TEXT NAME="prenom" SIZE=40><font size="2"> </font>
    </i>
    <p>
    <EM><font size="2">Adresse :</font></EM></p>
    <TEXTAREA NAME="adresse" ROWS=5 COLS=33 style="font-style: italic"></TEXTAREA><i><font size="2">
    </font>
    </i>
    <p>
    <EM><font size="2">Ville :</font></EM></p>
    <i>
    <INPUT TYPE=TEXT NAME="ville" SIZE=40><font size="2"> </font>
    </i>
    <p>
    <EM><font size="2">Code postal :</font></EM></p>
    <i>
    <INPUT TYPE=TEXT NAME="cp" SIZE=5 MAXLENGTH=5></i><p>
    <EM><font size="2">Téléphone portable :</font></EM></p>
    <i>
    <INPUT TYPE=TEXT NAME="telport" SIZE=10 MAXLENGTH=10><font size="2">
    </font>
    </i>
    <p>
    <EM><font size="2">Téléphone personnel :</font></EM></p>
    <i>
    <INPUT NAME="telpers" SIZE=10 MAXLENGTH=10><font size="2">
    </font>
    </i>
    <p>
    <EM><font size="2">Téléphone professionnel :</font></EM></p>
    <i>
    <INPUT NAME="telprof" SIZE=10 MAXLENGTH=10><font size="2">
    </font>
    </i>
    <p>
    <EM><font size="2">Courrier électronique :</font></EM></p>
    <i>
    <INPUT NAME="mail" SIZE=40><font size="2"> </font>
    </i>
    <p>
    <EM><font size="2">URL site web :</font></EM></p>
    <i>
    <INPUT NAME="url" SIZE=40 MAXLENGTH=25></i><p>
    <em><font size="2">Profession :</font></em></p>
    <i>
    <INPUT NAME="prof" SIZE=40></i><p align="left"><u><font size="2"><b><i>4</i></b></font></u><i><b><font size="2"><u>. Cotisation(s)</u></font></b><font size="2"> 
    (plusieurs choix sont possible)</font></i><p>
    <i><font size="2">&nbsp;* De base </font></i></p>
    <i><font size="2"><b><u>
    <SELECT NAME="cotb">
    <OPTION SELECTED>------------
    <OPTION>Base adhérent - 30 €
    <OPTION> Base moniteur - 30 €  
    <OPTION> Base AVF - 30 € 
    <OPTION> Base familiale - 30 € 
    </SELECT></u></b></font></i><p>
    <i><font size="2">* Formation </font></i> </p>
    <i><font size="2"><b><u>
    <SELECT NAME="cotf">
    <OPTION SELECTED>------------
    <OPTION>Formation adhérent - 60 €
    <OPTION> Formation AVF - 30 €   
    <OPTION> Formation familiale - 30 € 
    </SELECT></u></b></font></i><p>
    <i><font size="2">* Impression couleur</font></i></p>
    <i><font size="2"><b><u>
    <SELECT NAME="coti">
    <OPTION SELECTED>non
    <OPTION>oui 
    </SELECT></u></b></font></i><p>
    <i><font size="2">* Exonération de cotisation</font></i></p>
    <i><font size="2"><b><u>
    <SELECT NAME="cote">
    <OPTION SELECTED>non
    <OPTION>oui 
    </SELECT></u></b></font></i><p align="left"><u><font size="2"><b><i>5</i></b></font></u><b><i><u><font size="2">. Tranche âge&nbsp;:</font></u></i></b><p>
    <i><SELECT NAME="age">
    <OPTION SELECTED> - de 12 
    <OPTION> 12 - 18 
    <OPTION> 18 - 30 
    <OPTION> 30 - 40 
    <OPTION> 40 - 50 
    <OPTION> 50 - 60 
    <OPTION> 60 et + 
    </SELECT></i></p>
    <p align="left"><u><font size="2"><b><i>6</i></b></font></u><i><b><u><font size="2">. Adhésion familiale :</font></u></b><font size="2"> (1- prénom - nom - tranche 
    d'âge)</font></i><p align="center">
    <TEXTAREA NAME="fam" ROWS=5 COLS=60 style="font-style: italic"></TEXTAREA><p align="left"><u><font size="2"><b><i>7. </i></b></font></u><b><i><u>
    <font size="2">&nbsp;Animateur ?</font></u></i></b><P><i><INPUT TYPE=RADIO NAME="anim" VALUE="Oui" ><font size="2">
    Oui </font> <INPUT TYPE=RADIO NAME="anim" VALUE="Non" CHECKED><font size="2">
    Non</font></i></P>
    <u><font size="2"><b><i>8</i></b></font></u><b><i><u><font size="2">. Formateur ?</font></u></i></b><p>
    <i>
    <INPUT TYPE=RADIO NAME="form" VALUE="Oui" ><font size="2">
    Oui </font> <INPUT TYPE=RADIO NAME="form" VALUE="Non" CHECKED><font size="2"> Non</font></i></p>
    <p align="left"><u><font size="2"><b><i>9</i></b></font></u><b><i><u><font size="2">. CA ?</font></u></i></b><p align="left"><i><INPUT TYPE=RADIO NAME="ca" VALUE="Oui"><font size="2">
    Oui </font> <INPUT TYPE=RADIO NAME="ca" VALUE="Non" CHECKED><font size="2"> Non</font></i><p>
    <u><font size="2"><b><i>10</i></b></font></u><b><i><u><font size="2">. Bureau ?</font></u></i></b></p>
    <i>
    <INPUT TYPE=RADIO NAME="bur" VALUE="Oui"><font size="2">
    Oui </font> <INPUT TYPE=RADIO NAME="bur" VALUE="Non" CHECKED><font size="2"> Non</font></i><p align="left"><i><b><u><font size="2">11. Compétences particulaires :</font></u></b><font size="2"> (exemple : technique, 
    vidéo, photo...)</font></i><p>
    <TEXTAREA NAME="comp" ROWS=5 COLS=60 style="font-style: italic"></TEXTAREA><p align="left"><b><i><u><font size="2">12. Divers :</font></u></i></b><p>
    <TEXTAREA NAME="divers" ROWS=5 COLS=60 style="font-style: italic"></TEXTAREA></p>
    <p align="center">
    <INPUT TYPE=SUBMIT VALUE="Enregistrer"><font size="2">
    </font>
     
    <INPUT TYPE=RESET VALUE="Effacer le formulaire"></TD>
    </TR>
    <TR>&nbsp; 
    </TR>
    </TABLE>
    </BLOCKQUOTE>
    </FORM>
    </body>
    </html>

    Code PHP:
    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
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
     
    <? 
    $jj = $_POST['jj']; 
    $mm = $_POST['mm']; 
    $aa = $_POST['aa']; 
    $login = $_POST['login']; 
    $nom = $_POST['nom']; 
    $prenom = $_POST['prenom']; 
    $adresse = $_POST['adresse']; 
    $ville = $_POST['ville']; 
    $cp = $_POST['cp']; 
    $telport = $_POST['telport']; 
    $telpers = $_POST['telpers']; 
    $telprof = $_POST['telprof']; 
    $mail = $_POST['mail']; 
    $url = $_POST['url']; 
    $prof = $_POST['prof']; 
    $cotb = $_POST['cotb']; 
    $cotf = $_POST['cotf']; 
    $coti = $_POST['coti']; 
    $cote = $_POST['cote']; 
    $age = $_POST['age']; 
    $fam = $_POST['fam']; 
    $anim = $_POST['anim']; 
    $form = $_POST['form']; 
    $ca = $_POST['ca']; 
    $bur = $_POST['bur']; 
    $comp = $_POST['comp']; 
    $divers = $_POST['divers']; 
     
    // test de validité de la date 
    //test validité jour 
    if ($jj >=1 && $jj <= 31) 
    { 
    $bjj=1; 
    } 
    else 
    { 
    $bjj=0; 
    }; 
     
    //test validité mois 
    if ($mm >=1 && $mm <= 12) 
    { 
    $bmm=1; 
    } 
    else 
    { 
    $bmm=0; 
    }; 
     
    //test validité année 
    //recuperation de l'année en cours 
    $day = getdate(); 
    $year = $day['year']; 
     
    if ($aa >=1982 && $aa <= $year) 
    { 
    $baa=1; 
    } 
    else 
    { 
    $baa=0; 
    }; 
     
    //verification fevrier 
    if ($mm == 2 && $jj > 29) 
    { 
    echo "<br>Les mois de fevrier ne contient au mieux que 29 jours et non ".$jj.", faite attention !!!!!<br>"; 
    $bjm = 0; 
    } 
    else 
    { 
    $bjm =1; 
    } 
     
    // test global de date 
    if ($bjj==1&&$bmm==1&&$baa==1&&$bjm==1) 
    { 
    //connection au serveur 
    include("open.php"); 
     
    //Affichage table adherents de la bdd dans un tableau 
    include("aff_adh.php"); 
     
    // generation des variables pour la creation du num d'adh 
     
    if ($cote == "oui") 
      { 
      $cotf_refadh = 1; 
      $coti_refadh = 1; 
      } 
    else 
      { 
      if ($cotf == "------------") 
        { 
        $cotf_refadh = 0; 
        } 
        else 
        { 
        $cotf_refadh = 1; 
        } 
      if ($coti == "non") 
        { 
        $coti_refadh = 0; 
        } 
        else 
        { 
        $coti_refadh = 1; 
        } 
    }; 
     
    //regeration de la variable $refadh 
    echo "<br>"; 
    $refadh = $login.$jj.$mm.$aa."F".$cotf_refadh."I".$coti_refadh; 
     
    echo "<br>"; 
     
    //Insertion des données dans la table de la bdd 
    mysql_query("INSERT INTO adherents VALUES ('','$refadh','$jj','$mm','$aa','$login','$nom','$  prenom','$adresse','$ville','$cp','$telport','$tel  pers','$telprof','$mail','$url','$prof','$cotb','$  cotf','$coti','$cote','$age','$fam','$anim','$form  ','$ca','$bur','$comp','$divers')"); 
     
    //Affichage table adherents de la bdd dans un tableau 
    include("aff_adh.php"); 
     
    //fremeture de la connection au serveur 
    include("close.php"); 
    } 
    else 
    { 
    echo "<br>Attention vous avez fait des erreurs lors de la saisie de la date !!!<br>"; 
    } 
    // Récupération de l'url et création du liens de retour 
    $RETURN_LINK = $_SERVER['HTTP_REFERER']; 
    echo "<a href=\"$RETURN_LINK\">Retour</a><br>"; 
    ?>

  2. #2
    Membre expert Avatar de Amara
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    2 688
    Détails du profil
    Informations personnelles :
    Localisation : France, Sarthe (Pays de la Loire)

    Informations forums :
    Inscription : Juillet 2004
    Messages : 2 688
    Points : 3 115
    Points
    3 115
    Par défaut
    Etonnant... on pourrait avoir le code du formulaire ?


    Au passage je sais pas si ça fout la grouille ou pas mais il faut pas mettre de point-virgule après les accolades fermantes (des if).
    Pas de questions techniques par MP, le forum est là pour ça et est plus efficace.

    Orthographe : une connexion (avec un x), un langage (sans u), une requête (un seul t), 'une quote' (avec qu), une syntaxe (sans h)

  3. #3
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Points : 12 572
    Points
    12 572
    Par défaut
    tu aas testé ce que contenait les $variables que tu insere dans ta table ?

    au passage , tu ne fais aucune verification sur les données recuperer par $_POST[] donc ce n'est pas la peine de les ré assigner a des variables pour t'en servir plus bas .... dans ta requete sql passe directement les variables $_POST[] ... c est mon avis
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  4. #4
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 5
    Points : 2
    Points
    2
    Par défaut suite...
    Vl'a j'ai trouvé la solution grace a vos indications.
    J'ai modifier la partie ou je génère la requette mysql de cette façon :

    code php :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    $sql = "INSERT INTO adherents VALUES ('','".$_POST['refadh']."','".$_POST['jj']."','".$_POST['mm']."','".$_POST['aa']."','".$_POST['login']."','".$_POST['nom']."','".$_POST['prenom']."','".$_POST['adresse']."','".$_POST['ville']."','".$_POST['cp']."','".$_POST['telport']."','".$_POST['telpers']."','".$_POST['telprof']."','".$_POST['mail']."','".$_POST['url']."','".$_POST['prof']."','".$_POST['cotb']."','".$_POST['cotf']."','".$_POST['coti']."','".$_POST['cote']."','".$_POST['age']."','".$_POST['fam']."','".$_POST['anim']."','".$_POST['form']."','".$_POST['ca']."','".$_POST['bur']."','".$_POST['comp']."','".$_POST['divers']."')";
     
    echo $sql;
     
    mysql_query($sql);

    mais par contre la generation du code adherent ne marche plus du tout avez vous une idée d'où ça peur venir ?

    code complé de la page php :
    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
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
     
    <?
    include("retour.php");
     
    $jj = $_POST['jj'];
    $mm = $_POST['mm'];
    $aa = $_POST['aa'];
    $login = $_POST['login'];
    $nom = $_POST['nom'];
    $prenom = $_POST['prenom'];
    $adresse = $_POST['adresse'];
    $ville = $_POST['ville'];
    $cp = $_POST['cp'];
    $telport = $_POST['telport'];
    $telpers = $_POST['telpers'];
    $telprof = $_POST['telprof'];
    $mail = $_POST['mail'];
    $url = $_POST['url'];
    $prof = $_POST['prof'];
    $cotb = $_POST['cotb'];
    $cotf = $_POST['cotf'];
    $coti = $_POST['coti'];
    $cote = $_POST['cote'];
    $age = $_POST['age'];
    $fam = $_POST['fam'];
    $anim = $_POST['anim'];
    $form = $_POST['form'];
    $ca = $_POST['ca'];
    $bur = $_POST['bur'];
    $comp = $_POST['comp'];
    $divers = $_POST['divers'];
     
     
    //test de validité de la date
    //test validité jour
    if ($jj >=1 && $jj <= 31)
    {
    $bjj=1;
    }
    else
    {
    $bjj=0;
    }
     
    //test validité mois
    if ($mm >=1 && $mm <= 12)
    {
    $bmm=1;
    }
    else
    {
    $bmm=0;
    };
     
    //test validité année
    //recuperation de l'anné en cours
    $day = getdate();
    $year = $day['year'];
     
    if ($aa >=1982 && $aa <= $year)
    {
    $baa=1;
    }
    else
    {
    $baa=0;
    };
     
    //verification fevrier
    if ($mm == 2 && $jj > 29)
    {
    echo "<br>Les mois de fevrier ne contient au mieux que 29 jours et non ".$jj.", faite attention !!!!!<br>";
    $bjm = 0;
    }
    else
    {
    $bjm =1;
    };
     
    // test global de date
    if ($bjj==1&&$bmm==1&&$baa==1&&$bjm==1)
    {
    //connection au serveur
    include("open.php");
     
    //Affichage table de la bdd dans un tableau
    include("aff_adh.php");
     
    // generation des variables pour la creation du num d'adh
     
    if ($cote == "oui")
      {
      $cotf_refadh = 1;
      $coti_refadh = 1;
      }
    else
      {
      if ($cotf == "------------")
        {
        $cotf_refadh = 0;
        }
        else
        {
        $cotf_refadh = 1;
        };
      if ($coti == "non")
        {
        $coti_refadh = 0;
        }
        else
        {
        $coti_refadh = 1;
        }
    }
     
    //regeration de la variable $refadh
    echo "<br>";
    $refadh = $login.$jj.$mm.$aa."F".$cotf_refadh."I".$coti_refadh;
     
    echo "<br>";
     
    //Insertion des données dans la table adherent de la bdd acpi
    $sql = "INSERT INTO adherents VALUES ('','".$_POST['refadh']."','".$_POST['jj']."','".$_POST['mm']."','".$_POST['aa']."','".$_POST['login']."','".$_POST['nom']."','".$_POST['prenom']."','".$_POST['adresse']."','".$_POST['ville']."','".$_POST['cp']."','".$_POST['telport']."','".$_POST['telpers']."','".$_POST['telprof']."','".$_POST['mail']."','".$_POST['url']."','".$_POST['prof']."','".$_POST['cotb']."','".$_POST['cotf']."','".$_POST['coti']."','".$_POST['cote']."','".$_POST['age']."','".$_POST['fam']."','".$_POST['anim']."','".$_POST['form']."','".$_POST['ca']."','".$_POST['bur']."','".$_POST['comp']."','".$_POST['divers']."')";
     
    //echo $sql;
     
    mysql_query($sql);
     
     
     
    //Affichage table de la bddi dans un tableau pour verification
    include("aff_adh.php");
     
    //fremeture de la connection au serveur
    include("close.php");
    }
    else
    {
    echo "<br>Attention vous avez fait des erreurs lors de la saisie de la date !!!<br>";
    }
    include("retour.php");
    ?>

  5. #5
    Membre expert Avatar de Amara
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    2 688
    Détails du profil
    Informations personnelles :
    Localisation : France, Sarthe (Pays de la Loire)

    Informations forums :
    Inscription : Juillet 2004
    Messages : 2 688
    Points : 3 115
    Points
    3 115
    Par défaut
    Sympa de zapper les remarques...
    Pas de questions techniques par MP, le forum est là pour ça et est plus efficace.

    Orthographe : une connexion (avec un x), un langage (sans u), une requête (un seul t), 'une quote' (avec qu), une syntaxe (sans h)

  6. #6
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Points : 12 572
    Points
    12 572
    Par défaut
    c'est quoi la ligne sensée generer le code adherent ? parce que nous on a pas codé ton truc donc on sait pas trop lol ?
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    Salut a tous !
    Désolé d'avoir zappé les remarques.

    Donc j'ai bien testé les variables est elles on bien les bonnes valeurs.

    J'ai surpimer les ";" a la fin des boucle if.

    Pour la generation du code adhérent voila le code php que j'utilise :

    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
     
    // generation des variables pour la creation du num d'adh
     
    if ($cote == "oui")
      {
      $cotf_refadh = 1;
      $coti_refadh = 1;
      }
    else
      {
      if ($cotf == "------------")
        {
        $cotf_refadh = 0;
        }
        else
        {
        $cotf_refadh = 1;
        };
      if ($coti == "non")
        {
        $coti_refadh = 0;
        }
        else
        {
        $coti_refadh = 1;
        }
    }
     
    //regeration de la variable $refadh
    echo "<br>";
    $refadh = $login.$jj.$mm.$aa."F".$cotf_refadh."I".$coti_refadh;

  8. #8
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Points : 12 572
    Points
    12 572
    Par défaut
    [Mode extra lucide = on]

    Arrete moi si je me trompe : tu dis que le code adherent n 'est plus generé parce que dans ta base il est vide vrai ?

    EN fait ce n'est pas qu'il n 'est pas généré c est que tu ne l insere pas vrai ? (oui)

    Si tu ne l'insere pas c est parce que tu t'es planté dans la syntaxe de ta requete vrai ? (oui)

    le debut de ta requete suffit a le comprendre :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    $sql = "INSERT INTO adherents VALUES ('','".$_POST['refadh']."',

    tu ne passe aucune valeur refadh par ton formulaire donc tu as mis cette variable en $_POST[''] et elle est vide !


    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    $sql = "INSERT INTO adherents VALUES ('','".$refadh."',

    devrait marcher non ?
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  9. #9
    Candidat au Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    Merci pour ton "illumination" je crois que j'avais pas les yeux en face des trous.

    Mais du maitemant quand je rendre un nouvelle adhérent le code generé est le code de de l'adhérent precedent : exemple nouvelle adherent toto il me mais le num de ladherent tata que jai entré juste avant.
    Je pensse que ma variable ne se regenere pas comme il faut mais je vois pas ou.

    J'ai fait des echo de la variable refadh avant de faire generé le num d'adhérent puis aprés , elle contient les valeur de l'adh precedent.
    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
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
     
    <?
    include("retour.php");
    //$refadh = " ";
     
     
    //recup variables post
    $jj = $_POST['jj'];
    $mm = $_POST['mm'];
    $aa = $_POST['aa'];
    $login = $_POST['login'];
    $nom = $_POST['nom'];
    $prenom = $_POST['prenom'];
    $adresse = $_POST['adresse'];
    $ville = $_POST['ville'];
    $cp = $_POST['cp'];
    $telport = $_POST['telport'];
    $telpers = $_POST['telpers'];
    $telprof = $_POST['telprof'];
    $mail = $_POST['mail'];
    $url = $_POST['url'];
    $prof = $_POST['prof'];
    $cotb = $_POST['cotb'];
    $cotf = $_POST['cotf'];
    $coti = $_POST['coti'];
    $cote = $_POST['cote'];
    $age = $_POST['age'];
    $fam = $_POST['fam'];
    $anim = $_POST['anim'];
    $form = $_POST['form'];
    $ca = $_POST['ca'];
    $bur = $_POST['bur'];
    $comp = $_POST['comp'];
    $divers = $_POST['divers'];
     
    //test de validité de la date
    //test validité jour
    if ($jj >=1 && $jj <= 31)
    {
    $bjj=1;
    }
    else
    {
    $bjj=0;
    }
     
    //test validité mois
    if ($mm >=1 && $mm <= 12)
    {
    $bmm=1;
    }
    else
    {
    $bmm=0;
    };
     
    //test validité année
    //recuperation de l'anné en cours
    $day = getdate();
    $year = $day['year'];
     
    if ($aa >=1982 && $aa <= $year)
    {
    $baa=1;
    }
    else
    {
    $baa=0;
    };
     
    //verification fevrier
    if ($mm == 2 && $jj > 29)
    {
    echo "<br>Les mois de fevrier ne contient au mieux que 29 jours et non ".$jj.", faite attention !!!!!<br>";
    $bjm = 0;
    }
    else
    {
    $bjm =1;
    };
     
    // test global de date
    if ($bjj==1&&$bmm==1&&$baa==1&&$bjm==1)
    {
    //connection au serveur
    include("open.php");
     
    //Affichage table adherents de la bdd acpi dans un tableau
    include("aff_adh.php");
     
    // generation des variables pour la creation du num d'adh
    if ($cote == "oui")
      {
      $cotf_refadh = 1;
      $coti_refadh = 1;
      }
    else
      {
      if ($cotf == "------------")
        {
        $cotf_refadh = 0;
        }
        else
        {
        $cotf_refadh = 1;
        }
      if ($coti == "non")
        {
        $coti_refadh = 0;
        }
        else
        {
        $coti_refadh = 1;
        }
    }
     
    echo $refadh;
    //regeration de la variable $refadh
    echo "<br>";
    $refadh = $login.$jj.$mm.$aa."F".$cotf_refadh."I".$coti_refadh;
     
    echo $refadh;
    echo "<br>";
     
    //Insertion des données dans la table de la bdd 
    $sql = "INSERT INTO adherents VALUES ('','".$refadh."','".$_POST['jj']."','".$_POST['mm']."','".$_POST['aa']."','".$_POST['login']."','".$_POST['nom']."','".$_POST['prenom']."','".$_POST['adresse']."','".$_POST['ville']."','".$_POST['cp']."','".$_POST['telport']."','".$_POST['telpers']."','".$_POST['telprof']."','".$_POST['mail']."','".$_POST['url']."','".$_POST['prof']."','".$_POST['cotb']."','".$_POST['cotf']."','".$_POST['coti']."','".$_POST['cote']."','".$_POST['age']."','".$_POST['fam']."','".$_POST['anim']."','".$_POST['form']."','".$_POST['ca']."','".$_POST['bur']."','".$_POST['comp']."','".$_POST['divers']."')";
     
    //echo $sql;
     
    mysql_query($sql);
     
    //Affichage table de la bdd dans un tableau
    include("aff_adh.php");
     
    //fremeture de la connection au serveur
    include("close.php");
    }
    else
    {
    echo "<br>Attention vous avez fait des erreurs lors de la saisie de la date !!!<br>";
    }
    include("retour.php");
    ?>

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    82
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 82
    Points : 87
    Points
    87
    Par défaut
    Avant de generer ta refadh puis de l'inserer dans la base, tu utilise des includes :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    include("open.php");
    //Affichage table adherents de la bdd acpi dans un tableau
    include("aff_adh.php");
    si jamais, dans le code de l'un de ces includes, tu utilise la variable $login (par exemple dans aff_adh.php pour afficher la liste de tes adherents), l'erreur vient de là...

    [Mode extra lucide = off] (c'est pour ridekick, ...)

    @++
    "Soyez les changements que vous aimeriez voir dans le monde" Mahatma Gandhi

Discussions similaires

  1. Execute_query ne retourne pas les bonnes valeurs
    Par complicated dans le forum Forms
    Réponses: 2
    Dernier message: 23/11/2011, 11h12
  2. Requete qui n'affiche pas les bonnes valeurs
    Par snips67 dans le forum Langage SQL
    Réponses: 11
    Dernier message: 29/01/2010, 10h54
  3. Réponses: 3
    Dernier message: 12/05/2009, 15h30
  4. MySQL ne prend pas les ordres donnés par le script PHP
    Par arkelmy dans le forum Requêtes
    Réponses: 4
    Dernier message: 27/04/2006, 02h06

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