Page 1 sur 1

probleme sur un update

Posté : 19 juin 2009, 08:58
par stefanelle
Bonjour,

J ai un souci mon update ne fonctionne pas et je ne comprend pas pourquoi

Code : Tout sélectionner

$sql = "SELECT dvd, zone, format FROM general order by dvd"; $req = mysql_query($sql) or die( mysql_error() ) ; $total = mysql_num_rows($req); { echo '<form method="post" action="test.php">'; echo '<table>'."\n"; echo '<tr>'; echo '<th ><b><u>DVD.</u></b></th>'; echo '<th ><b><u>ZONE</u></b></th>'; echo '<th><b><u>FORMAT</u></b></th>'; echo '</tr>'."\n"; while($row = mysql_fetch_array($req)) { echo '<tr>'; echo '<td>'.$row["DVD"].'</td>'; echo '<td><input type="text" name="ZONE" value="'.$row["ZONE"].'"/></td>'; echo '<td><input type="text" name="format" value="'.$row["format"].'"/></td>'; echo '</tr>'."\n"; } echo '</table>'."\n"; echo '<input type="hidden" name="dvd2" value='.$_POST['dvd'].' /><br><center><input type="submit" name="ok" value="Modifier"/></center>'; echo '</form>'; } if (isset($_POST['ok'])) { $sql2= "UPDATE general SET zone='".$_POST['zone']."', format='".$_POST['format']."' WHERE dvd='".$_POST['dvd2']."'"; $req2= mysql_query($sql2) or die('Erreur SQL !'.$sql2.'<br>'.mysql_error()); if(isset($req2)) { echo "Modification OK" ; } } ?>

voici le résultat de l'echo devant mon $sql2

Code : Tout sélectionner

UPDATE general SET zone='18', format='0' WHERE dvd='/'Modification OK
il s'agit d'une ligne dans ma table comme si il la récupérait automatiquement très bizarre

Merci de votre aide

Posté : 19 juin 2009, 15:17
par Nagol
des quote dans les valeurs postées? :)
ca mériterais un coup de mysql_escape ca non?

Code : Tout sélectionner

if($req2)
serait plus adéquat

sinon ca peut venir du type de tes champs mysql, si tu lui colles '0' alors qu'il veut un int, ca va pas le faire donc faut virer les ' peut-être