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 :

suppression donnée du champ photo après modification


Sujet :

PHP & Base de données

  1. #1
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut suppression donnée du champ photo après modification
    Bonjour et bonne année
    je suis entrain de créer mon espace administration. J'ai une table articles avec un champ photo

    j'ai créer le fichier pour ajouter des articles, sans problème, maintenant je veux créer le fichier de modification avec un formulaire et un requête.

    formulaire et requête:
    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
    <form action="<?php echo $editFormAction; ?>" name="form1" id="form1" method="POST" >
                <table width="55%"  border="0" class="td">
                  <tr>
                    <td width="34%"><div align="left"></div></td>
                    <td width="66%"><div align="left">
                      <label></label>
                    </div></td>
                  </tr>
                  <tr>
                    <td><div align="left">Titre:</div></td>
                    <td><div align="left">
                      <label></label>
                      <label>
                      <input name="titre" type="text" id="titre" value="<?php echo $row_Rsmodifclient['titre']; ?>" size="32" />
                      </label>
                    </div></td>
                  </tr>
                  <tr>
                    <td><div align="left">Description:</div></td>
                    <td><label>
                      <div align="left">
                        <textarea name="description" cols="60" rows="3" id="description"><?php echo $row_Rsmodifclient['description']; ?></textarea>
                      </div>
                      </label></td>
                  </tr>
                  <tr>
                    <td><div align="left">prix:</div></td>
                    <td><label>
                      <div align="left">
                        <input name="prix" type="text" id="prix" value="<?php echo $row_Rsmodifclient['prix']; ?>" size="20" />
                      &euro;</div>
                      </label></td>
                  </tr>
                  <tr>
                    <td><div align="left">Image:</div></td>
                    <td><div align="left">
                      <label>
                      <input name="photo" type="file" id="photo" value="<?php echo $row_Rsmodifclient['photo']; ?>" size="50" />
                      </label>
                    </div></td>
                  </tr>
                  <tr>
                    <td><div align="left"></div></td>
                    <td><div align="left">
                      <input name="ID" type="hidden" id="ID" value="<?php echo $row_Rsmodifclient['reference']; ?>" />
                    </div></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="Submit" value="Modifier" /></td>
                  </tr>
                </table>
     
                <input type="hidden" name="MM_update" value="form1" />
              </form>
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s, photo=%s WHERE reference=%s",
                           GetSQLValueString($_POST['titre'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['prix'], "double"),
                           GetSQLValueString($_POST['photo'], "text"),
                           GetSQLValueString($_POST['ID'], "int"));
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient);
    Lorsque je modifie un champ autre que celui de la photo, le résultat est bon , mais en même temps, plus rien dans le champ photo. Je suis obligé de faire un 2ème passage pour remettre la photo.
    j'ai pensé à faire 2 requêtes une avec photo et l'autre sans, avec une condition, mais je n'arrive pas à élaborer ce code.
    pouvez-vous m'aider? Merci

  2. #2
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut
    j'ai essayé çà:
    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
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if (empty($_POST['photo'])) {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s, photo=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['photo'], "text"),
        GetSQLValueString($_POST['ID'], "int"));
        }
        else
        {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['ID'], "int"));
        }
     
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }  
      header(sprintf("Location: %s", $updateGoTo));
    }   
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient);
    mais j'ai parse error à la ligne 33 du code envoyé ci-dessus

  3. #3
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Une Parse error sur une accolade c'est souvent un problème de paires d'accolades. En l’occurrence je ne trouve pas où se trouve l'accolade ouvrante qui correspond à celle de la ligne 33...
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  4. #4
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut
    Merci de ta réponse Celira
    voici tout le code du début qui fonctionne sans 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
    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
    <?php require_once('../Connections/dream.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    	if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s, photo=%s WHERE reference=%s",
                           GetSQLValueString($_POST['titre'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['prix'], "double"),
                           GetSQLValueString($_POST['photo'], "text"),
                           GetSQLValueString($_POST['ID'], "int"));	
     
     
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient); 
     
    ?>
    et le code modifié pour obtenir le résultat souhaité:
    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
    <?php require_once('../Connections/dream.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
      if (empty($_POST['photo'])) {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s, photo=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['photo'], "text"),
        GetSQLValueString($_POST['ID'], "int"));
        }
        else
        {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['ID'], "int"));
        }			   			   
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient); 
     
    ?>
    parse error à la ligne 61 mentionné dans le code ci-dessus.

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

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juin 2006
    Messages : 2 451
    Points : 4 600
    Points
    4 600
    Par défaut
    comme dit plus haut, tu as une accollade en trop
    la ligne 61 correspond a l'accollade en trop...mais e n'est peut-etre pas celle la qu'il faut supprimer
    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 !

  6. #6
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut
    d'accord , mais si je l'enlève la modification ne se fait pas, je vais directement sur ma page valider.php ou j'ai mentionné que la modification à bien été effectuée.

  7. #7
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Je dirais plutôt qu'il manque la condition qui correspond à l'accolade ouvrante disparue : if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {.
    Ce qui donnerait :
    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
    <?php require_once('../Connections/dream.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      if (empty($_POST['photo'])) {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s, photo=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['photo'], "text"),
        GetSQLValueString($_POST['ID'], "int"));
     
     
      }
      else
      {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['ID'], "int"));
      }			   			   
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient); 
     
    ?>
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  8. #8
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut
    en effet plus d'erreur , mais malheureusement la photo est supprimée lorsque je fais une modification sur les autres champs.
    pas moyen de garder les données de ce champ photo, c'est à ne rien y comprendre.

  9. #9
    Membre actif
    Inscrit en
    Octobre 2006
    Messages
    368
    Détails du profil
    Informations forums :
    Inscription : Octobre 2006
    Messages : 368
    Points : 289
    Points
    289
    Par défaut
    j'ai essayé d'inverser la condition, effectivement après modification autre que la photo, celle-ci n'est pas supprimée.Mais si je veux modifier cette même photo et seulement celle-ci , c'est impossible.
    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
    <?php require_once('../Connections/dream.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
     
      if (empty($_POST['photo'])) { 
        $updateSQL = sprintf("UPDATE articles SET titre=%s, `description`=%s, prix=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),  
        GetSQLValueString($_POST['ID'], "int"));
        }
        else
        {
        $updateSQL = sprintf("UPDATE articles SET titre=%s, description`=%s, prix=%s, photo=%s WHERE reference=%s",
        GetSQLValueString($_POST['titre'], "text"),
        GetSQLValueString($_POST['description'], "text"),
        GetSQLValueString($_POST['prix'], "double"),
        GetSQLValueString($_POST['photo'], "text"), 
        GetSQLValueString($_POST['ID'], "int"));
        }   
     
      mysql_select_db($database_dream, $dream);
      $Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
     
      $updateGoTo = "valider.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    $colname_Rsmodifclient = "-1";
    if (isset($_GET['reference'])) {
      $colname_Rsmodifclient = $_GET['reference'];
    }
    mysql_select_db($database_dream, $dream);
    $query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
    $Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
    $row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
    $totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient); 
     
    ?>

Discussions similaires

  1. [WM18] Actualiser un champ combo après modification du fichier de données
    Par elvan49 dans le forum Windev Mobile
    Réponses: 3
    Dernier message: 17/11/2016, 17h20
  2. Réponses: 1
    Dernier message: 28/09/2012, 13h56
  3. Réponses: 5
    Dernier message: 20/09/2011, 18h55
  4. champs photo vide après modification profil
    Par yanng dans le forum Administration
    Réponses: 0
    Dernier message: 26/04/2009, 20h00
  5. Réponses: 2
    Dernier message: 27/02/2006, 10h18

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