touchcream Posted May 27, 2009 Posted May 27, 2009 Bonjour, j'ai un petit problème pour modifier un champ avec UPDATE. Tout devrait fonctionner mais non, la valeur du champ reste inchangée, elle ne prend pas la valeur de $compt et je ne comprends pas pourquoi :/ <?php mysql_connect("localhost", "root", "root");mysql_select_db("bdd");$var="test";$reponse = mysql_query("SELECT * FROM matable WHERE champ2='" . $var . "'");$compt = $donnees['vues'] + 1;echo $compt;mysql_query("UPDATE matable SET champ1='" . $compt . "' WHERE champ2='" . $var . "'");mysql_close();?>
captain_torche Posted May 27, 2009 Posted May 27, 2009 Essaye d'afficher une éventuelle erreur SQL, avec un or die(mysql_error()) après ta requête.
touchcream Posted May 27, 2009 Author Posted May 27, 2009 rien, il m'affiche gentillement la valeur de $compt conformément au echo mais le or die ne renvoi rien :/
captain_torche Posted May 27, 2009 Posted May 27, 2009 D'où vient ton tableau $données ? Si modification il y a, ton script ne permet pas de la voir. Tu as regardé directement dans la base (via PHPMyAdmin ou autre ?)
touchcream Posted May 27, 2009 Author Posted May 27, 2009 bon je m'en vais me fouetter très très fort, j'avais oublié de mettre while ($donnees = mysql_fetch_array($reponse) ) -_____- Merci beaucoup en tout cas
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now