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 :

Valeur qui ne s'ajoute pas dans une BDD [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut Valeur qui ne s'ajoute pas dans une BDD
    Bonjour,

    ceci est mon premier message sur votre forum .

    J'ai créer une page PHP dans laquelle je veux pouvoir remplir 4 champs pour les injecter dans ma base de données qui compte 4 champs

    (Numaff, Client, Nomaff, Resprojet)

    Voici le bout de code de ma page:

    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
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
     
     
    <?php require_once('../Connexions/ConnexionArchives.php'); ?>
    <?php
     
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
     
      switch ($theType) {
        case "varchar":
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Numaff";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "Client";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "Nomaff";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Resprojet";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . $_SERVER['QUERY_STRING'];
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
     
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
     
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
     
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
    $query_rsDossiers = "SELECT Numaff, Client, Nomaff, Resprojet FROM Archives ORDER BY Numaff";
    $rsDossiers = mysql_query($query_rsDossiers, $ConnexionArchives) or die(mysql_error());
    $row_rsDossiers = mysql_fetch_assoc($rsDossiers);
    $totalRows_rsDossiers = mysql_num_rows($rsDossiers);
    ?>
    <html><!-- InstanceBegin template="/Templates/PageArchives.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Pajout d'ajout de dossier aux archives</title>
    <!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>
     
    <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
    <table width="803" height="256" border="0" align="center" cellspacing="0">
    <tr align="right" valign="top">
    <td height="100" colspan="3" bordercolor="0"><div align="center">
    <p align="left"><strong><img src="../Images/logo.jpg" width="339" height="100"><img src="../Images/logo%20Archives.jpg" width="461" height="100"></strong></p>
    </div> </td>
    </tr>
    <tr valign="bottom">
    <td height="18" colspan="2"><div align="left"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">L.V.</font></div></td>
    <td height="18"><div align="right"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">v.1.2007</font></div></td>
    </tr>
    <tr align="center" valign="middle" background="../Images/Degrade2.jpg">
    <td width="230" height="35">
    <a href="../index.php"><font size="2"><font color="#666666" face="Arial, Helvetica, sans-serif"><strong>RECHERCHE</strong></font></font></a> </td>
    <td width="335" height="35"><div align="center">
    <div align="center"> </div> </td>
    <td width="238" height="35"><div align="center">
    <select name="menuListes" onChange="MM_jumpMenu('parent',this,0)">
    <option>-- LISTES DES DOSSIERS -- </option>
    <option value="../Listes/listenumaff.php">Par N&deg; affaire</option>
    <option value="../Listes/listeclient.php">Par nom du client</option>
    <option value="../Listes/listenomaff.php">Par titre de l'affaire</option>
    <option value="../Listes/listeresprojet.php">Par responsables de projets</option>
    </select>
    </div></td>
    </tr>
    <tr bgcolor="#F2F2F2">
    <td height="58" colspan="3"><div align="center"><font size="6"><font face="Arial, Helvetica, sans-serif"></font></font>
    <p><font size="6"><!-- InstanceBeginEditable name="EditRegion1" --><font face="Arial, Helvetica, sans-serif">AJOUT
    d'un dossier aux archives</font><!-- InstanceEndEditable --></font></p>
    </div>
    <div align="center"></div> <div align="right"></div> <table width="97%" height="43%" align="center">
    <tr>
    <td width="80%" height="34"><div align="center"><!-- InstanceBeginEditable name="EditRegion2" -->
    <form name="form1" method="form1" action="
    <?php echo $editFormAction; ?>
    ">
    <p align="left"><font size="2"> </font></p>
    </form>
    <form method="post" name="form2" action="
    <?php echo $editFormAction; ?>
    ">
    <table width="530" align="center">
    <tr valign="baseline">
    <td width="0" align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">N&deg; d'affaire:</font></div></td>
    <td width="370"><font size="2" face="Arial, Helvetica, sans-serif">
    <input type="text" name="Numaff" value="" size="50">
    </font></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Client: </font></div></td>
    <td><font size="2" face="Arial, Helvetica, sans-serif">
    <input type="text" name="Client" value="" size="50">
    </font></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Nom de l'affaire:</font></div></td>
    <td><font size="2" face="Arial, Helvetica, sans-serif">
    <input type="text" name="Nomaff" value="" size="50">
    </font></td>
    </tr>
    <tr valign="baseline">
    <td align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Responsable projet :</font></div></td>
    <td><div align="left"><font size="2" face="Arial, Helvetica, sans-serif">
    <input type="text" name="Resprojet" value="" size="50">
    </font></div></td>
    </tr>
    <tr valign="baseline">
    <td colspan="2" align="right" nowrap><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
    <input name="submit" type="submit" value="Valider l'ajout du dossier">
    </font></div></td>
    </tr>
    </table>
    <input type="hidden" name="Numaff" value="">
    <input type="hidden" name="MM_insert" value="form2">
    </form>
    <!-- InstanceEndEditable --></div> </td>
    </tr>
    </table> </td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    <!-- InstanceEnd --></html>
    --------------------------------------------------

    En remplissant les champs dans l'ordre suivant :

    N° affaire : D1111
    Client: 1
    Nom affaire: 2
    Resp. projet: 3

    Lorsque je valide j'obtiens ce genre de message:

    Duplicata du champ '' pour la clef 1

    Sachant que Numaff est définie en UNIQUE

    Merci de votre aide

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    314
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 314
    Points : 206
    Points
    206
    Par défaut
    Le message est clair, la variable numaff n'a pas été prise en compte du coup tu insère un champ vide une première fois dans ta base. La seconde fois vu que c'est un champ unique tu as une erreur mysql.
    Fais un echo de ta requête avant de l'exécuter...
    Nulla dies sin linea

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut
    Et comment fais-tu ça STP ???

  4. #4
    Membre confirmé Avatar de yjuliet
    Homme Profil pro
    Consultant en sécurité
    Inscrit en
    Août 2006
    Messages
    362
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : Consultant en sécurité
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Août 2006
    Messages : 362
    Points : 460
    Points
    460
    Par défaut
    Pour ce faire, tu vas dans ton code, et du modifies
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
     
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
    en
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
      //!- DEBUT AJOUT
      echo $insertSQL."<br/>\n";
      //!- FIN AJOUT
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut Cool
    Toi t'es un bon !!!!

    J'essaies ça demain matin au boulot et je te tiens informé ..

    Merci beaucoup ...

    A plus

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut Dommage
    J'ai modifié ce que tu m'as dis mais voilà l'erreur qu'il me retourne:

    Duplicata du champ '' pour la clef 1

    Et mon champ n'est tjs pas rempli ....

    Dommage ...

    Je bidouille encore ...

  7. #7
    Expert confirmé
    Avatar de Doksuri
    Profil pro
    Développeur Web
    Inscrit en
    Juin 2006
    Messages
    2 465
    Détails du profil
    Informations personnelles :
    Âge : 54
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juin 2006
    Messages : 2 465
    Points : 4 650
    Points
    4 650
    Par défaut
    salut,
    vérifie ta clé primaire...si ca se trouve elle existe déja
    La forme des pyramides prouve que l'Homme a toujours tendance a en faire de moins en moins.

    Venez discuter sur le Chat de Développez !

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut
    Oui elle existe mais quand je l'efface de la BDD et je remplis de nouveau mes 4 champs comme ça:

    D1111
    11
    11
    11


    Il ne me remplis que les 3 dernières lignes dans ma BDD et pas moyen de mettre le D1111 ou n'importe quelle autre valeurs ....

    Quelle que soit la valeur de D.... Il me retourne à chaque fois la même erreur ...

    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
     
     
    switch ($theType) {
        case "varchar":
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Numaff";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "Client";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "Nomaff";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Resprojet";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    Je pense que ça à quelque chose à voir avec la première ligne:

    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Numaff";
    break;

    Si je change la valeur de "Numaff" en "1234" il m'ajoute la ligne mais en écrivant 1234 dans le champ N° affaire ... Puis si je recommence à rajouter une ligne le message d'erreur reviens:

    Duplicata du champ '1234' pour la clef 1

    Alors que les autres champs se rajoutent correctement.

    Voici le code ma page en entier:

    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
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
     
     
    <?php require_once('../Connexions/ConnexionArchives.php'); ?>
    <?php
     
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
     
      switch ($theType) {
        case "varchar":
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "1234";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "Client";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "Nomaff";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Resprojet";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . $_SERVER['QUERY_STRING'];
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
     
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
      //!- DEBUT AJOUT
      echo $insertSQL,"<br/>\n";
      //!- FIN AJOUT
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
     
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
    $query_rsDossiers = "SELECT Numaff, Client, Nomaff, Resprojet FROM Archives ORDER BY Numaff";
    $rsDossiers = mysql_query($query_rsDossiers, $ConnexionArchives) or die(mysql_error());
    $row_rsDossiers = mysql_fetch_assoc($rsDossiers);
    $totalRows_rsDossiers = mysql_num_rows($rsDossiers);
    ?>
    <html><!-- InstanceBegin template="/Templates/PageArchives.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Pajout d'ajout de dossier aux archives</title>
    <!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>
     
    <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
    <table width="803" height="256" border="0" align="center" cellspacing="0">
      <tr align="right" valign="top">
        <td height="100" colspan="3" bordercolor="0"><div align="center">
            <p align="left"><strong><img src="../Images/logo.jpg" width="339" height="100"><img src="../Images/logo%20Archives.jpg" width="461" height="100"></strong></p>
        </div>      </td>
      </tr>
      <tr valign="bottom">
        <td height="18" colspan="2"><div align="left"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">L.V.</font></div></td>
        <td height="18"><div align="right"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">v.1.2007</font></div></td>
      </tr>
      <tr align="center" valign="middle" background="../Images/Degrade2.jpg">
        <td width="230" height="35">
        <a href="../index.php"><font size="2"><font color="#666666" face="Arial, Helvetica, sans-serif"><strong>RECHERCHE</strong></font></font></a>   </td>
        <td width="335" height="35"><div align="center">
        <div align="center">    </div>      </td>
        <td width="238" height="35"><div align="center">
            <select name="menuListes" onChange="MM_jumpMenu('parent',this,0)">
              <option>-- LISTES DES DOSSIERS -- </option>
              <option value="../Listes/listenumaff.php">Par N&deg; affaire</option>
              <option value="../Listes/listeclient.php">Par nom du client</option>
              <option value="../Listes/listenomaff.php">Par titre de l'affaire</option>
              <option value="../Listes/listeresprojet.php">Par responsables de projets</option>
            </select>
        </div></td>
      </tr>
      <tr bgcolor="#F2F2F2">
        <td height="58" colspan="3"><div align="center"><font size="6"><font face="Arial, Helvetica, sans-serif"></font></font>
          <p><font size="6"><!-- InstanceBeginEditable name="EditRegion1" --><u><font face="Arial, Helvetica, sans-serif">AJOUT
                  d'un dossier aux archives</font></u><!-- InstanceEndEditable --></font></p>
          </div>      
        <div align="center"></div>      <div align="right"></div>      <table width="97%" height="43%" align="center">
            <tr>
              <td width="80%" height="34"><div align="center"><!-- InstanceBeginEditable name="EditRegion2" -->
        <form name="form1" method="form1" action="<?php echo $editFormAction; ?>">
            <p align="left"><font size="2"> </font></p>
            </form>
        <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
          <table width="530" align="center">
            <tr valign="baseline">
              <td width="0" align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">N&deg; d'affaire:</font></div></td>
              <td width="370"><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Numaff" value="" size="50">
    </font></td>
              </tr>
            <tr valign="baseline">
              <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Client:  </font></div></td>
              <td><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Client" value="" size="50">
              </font></td>
              </tr>
            <tr valign="baseline">
              <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Nom de l'affaire:</font></div></td>
              <td><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Nomaff" value="" size="50">
              </font></td>
              </tr>
            <tr valign="baseline">
              <td align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Responsable projet :</font></div></td>
              <td><div align="left"><font size="2" face="Arial, Helvetica, sans-serif">
                 <input type="text" name="Resprojet" value="" size="50">
              </font></div></td>
            </tr>
            <tr valign="baseline">
              <td colspan="2" align="right" nowrap><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
                  <input name="submit" type="submit" value="Valider l'ajout du dossier">
              </font></div></td>
            </tr>
          </table>
          <input type="hidden" name="Numaff" value="">
          <input type="hidden" name="MM_insert" value="form2">
        </form>
        <!-- InstanceEndEditable --></div>          </td>
            </tr>
          </table>    </td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    <!-- InstanceEnd --></html>

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut
    A quoi correspond exactement ça:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
     
    <form name="form1" method="form1" action="<?php echo $editFormAction; ?>">
            <p align="left"><font size="2"> </font></p>
            </form>
        <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
          <table width="530" align="center">
            <tr valign="baseline">
    Pourquoi la première: <form name="form1"
    Et la deuxième: <form method="post"

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 89
    Points : 26
    Points
    26
    Par défaut Resolu
    C'est bon j'ai trouvé d'ou venais le problème :

    Voici le code ma page (+ ou - "optimisé") :

    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
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
     
     
    <?php require_once('../Connexions/ConnexionArchives.php'); ?>
    <?php
     
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
     
      switch ($theType) {
        case "varchar":
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Numaff";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "Client";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "Nomaff";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "Resprojet";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . $_SERVER['QUERY_STRING'];
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
     
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO Archives (Numaff, Client, Nomaff, Resprojet) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['Numaff'], "text"),
                           GetSQLValueString($_POST['Client'], "text"),
                           GetSQLValueString($_POST['Nomaff'], "text"),
                           GetSQLValueString($_POST['Resprojet'], "text"));
      //!- DEBUT AJOUT
      echo $insertSQL,"<br/>\n";
      //!- FIN AJOUT
      mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
      $Result1 = mysql_query($insertSQL, $ConnexionArchives) or die(mysql_error());
     
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    mysql_select_db($database_ConnexionArchives, $ConnexionArchives);
    $query_rsDossiers = "SELECT Numaff, Client, Nomaff, Resprojet FROM Archives ORDER BY Numaff";
    $rsDossiers = mysql_query($query_rsDossiers, $ConnexionArchives) or die(mysql_error());
    $row_rsDossiers = mysql_fetch_assoc($rsDossiers);
    $totalRows_rsDossiers = mysql_num_rows($rsDossiers);
    ?>
    <html><!-- InstanceBegin template="/Templates/PageArchives.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Pajout d'ajout de dossier aux archives</title>
    <!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    </head>
     
    <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
    <table width="803" height="256" border="0" align="center" cellspacing="0">
      <tr align="right" valign="top">
        <td height="100" colspan="3" bordercolor="0"><div align="center">
            <p align="left"><strong><img src="../Images/logo%20CMF.jpg" width="339" height="100"><img src="../Images/logo%20Archives.jpg" width="461" height="100"></strong></p>
        </div>      </td>
      </tr>
      <tr valign="bottom">
        <td height="18" colspan="2"><div align="left"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">L.V.</font></div></td>
        <td height="18"><div align="right"><font color="0494bc" size="2" face="Arial, Helvetica, sans-serif">v.1.2007</font></div></td>
      </tr>
      <tr align="center" valign="middle" background="../Images/Degrade2.jpg">
        <td width="230" height="35">
        <a href="../index.php"><font size="2"><font color="#666666" face="Arial, Helvetica, sans-serif"><strong>RECHERCHE</strong></font></font></a>   </td>
        <td width="335" height="35"><div align="center">
        <div align="center">    </div>      </td>
        <td width="238" height="35"><div align="center">
            <select name="menuListes" onChange="MM_jumpMenu('parent',this,0)">
              <option>-- LISTES DES DOSSIERS -- </option>
              <option value="../Listes/listenumaff.php">Par N&deg; affaire</option>
              <option value="../Listes/listeclient.php">Par nom du client</option>
              <option value="../Listes/listenomaff.php">Par titre de l'affaire</option>
              <option value="../Listes/listeresprojet.php">Par responsables de projets</option>
            </select>
        </div></td>
      </tr>
      <tr bgcolor="#F2F2F2">
        <td height="58" colspan="3"><div align="center"><font size="6"><font face="Arial, Helvetica, sans-serif"></font></font>
          <p><font size="6"><!-- InstanceBeginEditable name="EditRegion1" --><u><font face="Arial, Helvetica, sans-serif">AJOUT
                  d'un dossier aux archives</font></u><!-- InstanceEndEditable --></font></p>
          </div>      
        <div align="center"></div>      <div align="right"></div>      <table width="97%" height="43%" align="center">
            <tr>
              <td width="80%" height="34"><div align="center"><!-- InstanceBeginEditable name="EditRegion2" -->
        <form name="form1" method="form1" action="<?php echo $editFormAction; ?>">
            <p align="left"><font size="2"> </font></p>
            </form>
        <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
          <table width="530" align="center">
            <tr valign="baseline">
              <td width="0" align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">N&deg; d'affaire:</font></div></td>
              <td width="370"><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Numaff" value="" size="50">
    </font></td>
              </tr>
            <tr valign="baseline">
              <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Client:  </font></div></td>
              <td><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Client" value="" size="50">
              </font></td>
              </tr>
            <tr valign="baseline">
              <td nowrap align="right"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Nom de l'affaire:</font></div></td>
              <td><font size="2" face="Arial, Helvetica, sans-serif">
                <input type="text" name="Nomaff" value="" size="50">
              </font></td>
              </tr>
            <tr valign="baseline">
              <td align="right" nowrap><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Responsable projet :</font></div></td>
              <td><div align="left"><font size="2" face="Arial, Helvetica, sans-serif">
                 <input type="text" name="Resprojet" value="" size="50">
              </font></div></td>
            </tr>
            <tr valign="baseline">
              <td colspan="2" align="right" nowrap><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
                  <input name="submit" type="submit" value="Valider l'ajout du dossier">
              </font></div></td>
            </tr>
          </table>
     	  <input type="hidden" name="MM_insert" value="form2">
        </form>
        <!-- InstanceEndEditable --></div>          </td>
            </tr>
          </table>    </td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    <!-- InstanceEnd --></html>
    L'erreur venait du faite que j'avais essayé en mettant dans ma BDD le champ Numaff en PRIMARY et j'ai essayé aussi en UNIQUE ... AUCUN N° Affaire de s'insérait.

    Alors j'ai mis le champ en INDEX avec un autre champ ID pour en AUTO_INCREMENT ca me permettra de savoir a combien de dossier j'en suis rapidement ...ET LA NICKEL le numéro d'affaire D1111 ou autre s'insère ....

    Merci de votre participation ...

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

Discussions similaires

  1. Réponses: 5
    Dernier message: 07/06/2011, 13h27
  2. [ADO] Requete qui ne s'execute pas dans une transaction
    Par Faboul dans le forum VBA Access
    Réponses: 1
    Dernier message: 17/07/2007, 13h30
  3. Réponses: 6
    Dernier message: 22/05/2007, 09h55
  4. [MySQL] slashes qui ne s'ajoutent pas dans la bd
    Par Sayrus dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 08/03/2007, 18h46
  5. excel: colonne qui ne s'affiche pas dans une liste
    Par fast&furious dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 19/07/2006, 18h12

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