Bonjour,

J'ai créé une page nommé "mon-profil.php" qui est utilisée pour modifier les informations de son compte (mail, mdp, ...).

Un formulaire y est présent pour modifier les champs (normal). Mais je ne parvient pas à modifier les valeurs de la table en question.

Voici la totalité de la 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
<?php $title='Mon profil'; ?>  
<?php include ("head.php"); ?>  
<?php include("banniere.php"); ?>  
<table width="1015px" border="0" align="center">  
  <tr>  
    <th class="hleft" width="4"> </th>  
    <th class="hmiddle"><?php echo $title; ?></th>  
    <th class="hright" width="4"> </th>  
  </tr>  
  <tr>  
    <td class="page" colspan="3" width="1"><hr /></td>  
  </tr>  
  <tr>  
    <td class="page" colspan="3" align="center">
      <?php
 
      ?>
      <?php
        if ($id != '0')
          {
          $dn = mysql_query('select * from membre where id="'.$id.'"');
          if(mysql_num_rows($dn)>0)
            {
            $dnn = mysql_fetch_array($dn);
            $error = FALSE;
            $registerOK = FALSE;
            if(isset($_POST["modification"]))
              {
              if(empty($_POST["passwd"]) OR empty($_POST["passwd1"]) OR empty($_POST["mail"]) OR empty($_POST["reponse"]))
                {
                echo '<font color="#990000"><b>Vous devez obligatoirement remplire les champs suivant :<br />Mail, Mot de passe, Confirmation de mot de passe et R&eacute;ponse secr&egrave;te !</b></font>';
              }
              else
                {
                if ($_POST['passwd'] != $_POST['passwd1'])
                  {
                  echo '<font color="#990000"><b>Les deux mot de passe sont diff&eacute;rent !</b></font>';
                }
                else
                  {
                  if(!filter_var($_POST["mail"], FILTER_VALIDATE_EMAIL))
                    {
                    echo '<font color="#990000"><b>Votre adresse Mail est incorrecte !</b></font>';
                  }
                  else
                    {
                    if($_POST['reponse'] != $dnn['r_secret'])
                      {
                      echo '<font color="#990000"><b>Votre r&eacute;ponse secr&egrave;te est incorrecte !</b></font>';
                    }
                    else
                      {
                      $sql = mysql_query('UPDATE membre SET passwd = '.MD5($_POST['passwd']).', mail = '.htmlentities($_POST['mail'], ENT_QUOTES, 'UTF-8').', presentation = '.htmlentities($_POST['presentation'], ENT_QUOTES, 'UTF-8').' WHERE id ='.$id);  
                      if($sql)  
                        {                           
                        echo '<font color="#009900"><b>Modifications r&eacute;ussie !</b></font>';  
                      }  
                      else  
                        {                           
                        echo '<font color="#990000"><b>Erreur dans la requ&ecirc;te SQL</b></font>';  
                      }
                    }
                  }
                }
              }
            }
      ?>  
<form action="mon-profil.php" method="POST">  
<table width="63%" name="informations" align="center" border="0">  
  <tr>  
    <td valign="bottom" colspan="3" align="center"><font size="+1">Modifiez votre profil</font></td>  
  </tr>  
  <tr>  
    <td valign="top" width="102" align="center"><?php echo html_entity_decode($dnn['pseudo'], ENT_QUOTES, 'UTF-8'); ?><br />  
      <?php echo '<img src="images/avatars/membres/'.html_entity_decode($dnn['avatar'], ENT_QUOTES, 'UTF-8').'.png" alt="Avatar du membre" style="max-width:100px;max-height:100px;" /><br />'; ?>  
      <a href="#"><u>Modifier mon avatar</u></a>  
    </td>  
    <td class="left" valign="top">  
      <table>  
        <tr>  
          <td><font color="#990000"><b>*</b></font>Changer d'adresse mail</td>  
          <td><?php echo '<input type="text" name="mail" value="'.html_entity_decode($dnn['mail'], ENT_QUOTES, 'UTF-8').'"/>'; ?></td>  
        </tr>  
        <tr>          
          <td><font color="#990000"><b>*</b></font>Nouveau mot de passe</td>  
          <td><input type="password" name="passwd" /></td>  
        </tr>  
        <tr>  
          <td><font color="#990000"><b>*</b></font>Confirmez mot de passe</td>  
          <td><input type="password" name="passwd1" /></td>  
        </tr>  
      </table>  
    </td>  
    <td valign="top" width="220px" style="border-width:0 0 0 1px; border-style:solid; border-color:#000000;">  
      Question secrète :<br />
      <font color="#000099"><?php echo html_entity_decode($dnn['q_secret'], ENT_QUOTES, 'UTF-8'); ?></font><br />  
      <font color="#990000"><b>*</b></font>Réponse secrète :<br />
      <input name="reponse" type="text" />  
    </td>  
  </tr>  
  <tr>  
    <td colspan="3" style="border-width:1px 0 0 0; border-style:solid; border-color:#000000;" align="center">  
      <h3>Présentation :</h3>  
    </td>  
  </tr>  
  <tr>  
    <td class="left" valign="top" colspan="3" align="center">  
      <pre><textarea name="presentation"><?php echo html_entity_decode($dnn['presentation'], ENT_QUOTES, 'UTF-8'); ?></textarea></pre>  
    </td>  
  </tr>  
  <tr>  
    <td colspan="3" style="border-width:1px 0 0 0; border-style:solid; border-color:#000000;" align="center">  
      <h3>Personnage Lié</h3>  
    </td>  
  </tr>  
  <tr>  
    <td colspan="3" valign="top">  
      <table width="87%" align="center" border="1">  
        <tr>  
          <td align="center" valign="top">Pseudo</td>  
          <td align="center" valign="top">Classe</td>  
          <td align="center" valign="top" width="50">Niveau</td>  
          <td align="center" valign="top">Serveur</td>  
        </tr>  
        <?php  
          $sql = 'select id_personnage, id_membre, classe, pseudo, serveur, niveau from personnage where id_membre="'.$id.'"';  
          $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());  
          while($data = mysql_fetch_assoc($req))  
            {  
              echo '<tr><td align="center" valign="top"><a href="personnage.php?id='.html_entity_decode($data['id_personnage'], ENT_QUOTES, 'UTF-8').'" style="text-decoration:none;color:#000099;"><u>'.html_entity_decode($data['pseudo'], ENT_QUOTES, 'UTF-8').'</u></a></td><td align="center" valign="top"><font color="000099">'.html_entity_decode($data['classe'], ENT_QUOTES, 'UTF-8').'</font></td><td align="center" valign="top">'.html_entity_decode($data['niveau'], ENT_QUOTES, 'UTF-8').'</td><td align="center" valign="top">'.html_entity_decode($data['serveur'],ENT_QUOTE, 'UTF-8').'</td></tr>';  
          }  
        ?>  
        <?php  
          $sql = 'select COUNT(*) from personnage WHERE id_membre="'.$id.'"';  
          $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());  
          $data = mysql_fetch_array($req);  
          if ($data[0] == '0')  
            {  
            echo '<tr><td colspan="4" align="center" valign="top" style="background-color:#ff0000;"><font color="#ffffff">Vous n\'avez pas de personnage lié</font></td></tr>';  
          }  
        ?>  
        <tr><td colspan="4" align="center" valign="top" style="background-color:#009900;"><a href="#"><font color="#000000"><b>Créer un nouveau personnage</b></font></a></td></tr>  
      </table>  
    </td>          
  </tr>  
  <tr>  
    <td colspan="3" align="center">  
      <input name="modification" value="Enregistrer les modifications" type="submit">  
    </td>  
  </tr>  
</table>  
</form>  
      <?php
          }
          else
            { echo 'Utilisateur inconu !';
          }
        }
        else
          { echo 'Vous devez vous connecter pour afficher cette page !<br /><a href="connexion.php">Connexion</a> - <a href="inscription">Inscription</a>';
        }   
?>  
    </td>  
  </tr>  
</table>  
<?php include("copyright.php"); ?>
Problème rencontré : Quand je clique sur "Enregistrer les modifications", je suis bien redirigé vers la page en question (mon-profil.php), mais j'ai ceci qui s'affiche : "Erreur dans la requête SQL"

Ce message s'affiche suite à ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
{
$sql = mysql_query('UPDATE membre SET passwd = '.MD5($_POST['passwd']).', mail = '.htmlentities($_POST['mail'], ENT_QUOTES, 'UTF-8').', presentation = '.htmlentities($_POST['presentation'], ENT_QUOTES, 'UTF-8').' WHERE id ='.$id);  
 if($sql) {                           
echo '<font color="#009900"><b>Modifications r&eacute;ussie!</b></font>';}  
 else{                           
echo '<font color="#990000"><b>Erreur dans la requ&ecirc;te SQL</b></font>';}
}
Ce code mysql (update) est utilisé pour modifier les valeurs enregistré dans la base de données (je suis bien connecté à la base de donnée). Et je souhaite modifier les informations d'un membre au quel sont id de membre (auto incrémenté et donc unique) est $id

Je ne trouve pas la source du problème, pourriez-vous me guider ?


Merci d'avance