update problematique

Eléphant du PHP | 200 Messages

03 mars 2005, 09:48

Bonjour tlm :!:
En ce moment je travaille sur une appli de carnet d'adresse et je m 'arrache les cheveux :shock: ....je bloque sur une requete UPDATE qui me rend folle ...

Ma table :

Code : Tout sélectionner

CREATE TABLE `address_book` ( `address_book_id` int(11) NOT NULL auto_increment, `customers_id` int(11) NOT NULL default '0', `entry_gender` char(1) NOT NULL default '', `entry_company` varchar(32) default NULL, `entry_firstname` varchar(32) NOT NULL default '', `entry_lastname` varchar(32) NOT NULL default '', `entry_street_address` varchar(250) NOT NULL default '', `entry_suburb` varchar(32) default NULL, `entry_postcode` varchar(10) NOT NULL default '', `entry_city` varchar(32) NOT NULL default '', `entry_state` varchar(32) default NULL, `entry_country_id` int(11) NOT NULL default '240', `entry_zone_id` int(11) NOT NULL default '0', PRIMARY KEY (`address_book_id`), KEY `idx_address_book_customers_id` (`customers_id`) ) ;
et mon bout de code

Code : Tout sélectionner

<?php case 1 : //Modification d'une adresse if ($s_etape=="1") { if (isset($_POST['nom'])){ $nom = $_POST['nom']; } if (isset($_POST['gender'])){ echo $gender = $_POST['gender']; } if (isset($_POST['prenom'])){ $prenom = $_POST['prenom']; } if (isset($_POST['societe'])){ $societe = $_POST['societe']; } if (isset($_POST['adresse'])){ $adresse = $_POST['adresse']; } if (isset($_POST['adresse2'])){ $adresse2 = $_POST['adresse2']; } if (isset($_POST['cp'])){ $cp = $_POST['cp']; } if (isset($_POST['ville'])){ $ville =$_POST['ville']; } if (isset($_POST['address_book_id'])){ $address_book_id =$_POST['address_book_id']; } $adresse=$adresse." ".$adresse2; //$q_3=mysql_query("UPDATE address_book SET entry_gender='$gender' AND entry_firstname='$prenom' AND entry_lastname='$nom' AND entry_street_address='$adresse' AND entry_postcode='$cp' AND entry_city='$ville' WHERE address_book_id='$address_book_id'"); echo "UPDATE address_book SET entry_gender='".$gender."' AND entry_company='".$societe."' AND entry_firstname='".$prenom."' AND entry_lastname='".$nom."' AND entry_street_address='".$adresse."' AND entry_postcode='".$cp."' AND entry_city='".$ville."' WHERE address_book_id='".$address_book_id."'"; } ?> <?php $q_2=mysql_query("SELECT address_book_id,customers_id,entry_gender,entry_company,entry_firstname,entry_lastname,entry_street_address,entry_postcode,entry_city FROM address_book WHERE address_book_id='$cid' "); $r_2=mysql_fetch_array($q_2); $address_book_id=$r_2['address_book_id']; echo $entry_gender=$r_2['entry_gender']; $entry_company=$r_2['entry_company']; $entry_firstname=$r_2['entry_firstname']; $entry_lastname=$r_2['entry_lastname']; $entry_street_address=$r_2['entry_street_address']; $entry_postcode=$r_2['entry_postcode']; $entry_city=$r_2['entry_city']; ?> <form action="mon_carnet.php" target="_self" method="post" onSubmit="return veri()" name="f1"> <input name="address_book_id" value="<?php echo $address_book_id;?>" type="hidden"> <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="style1"> <tr > <td colspan="2" ><a href="#" class="style4" target="_self" rel="navigation"><img src="images_template/flec.gif" border="0" name="fleche">&nbsp;Modification :</a></td> </tr> <tr> <td colspan="2" class="minifichesousrub" >Adresse secondaire </td> </tr> <tr> <td colspan="2" ><img src="images_template/1x1.gif" width="1" height="15"></td> </tr> <tr class="catcentralmini1"> <td width="100" >Sociéte</td> <td ><input name="societe" value="<?php echo $entry_company;?>" size="20" maxlength="20"></td> </tr> <tr> <td>Civilité</td> <td colspan="2">Mme/Mll<input type="radio" name="gender" value="f" <?php if($entry_gender =="f") { echo " checked";} ?>> Mr<input type="radio" name="gender" value="m" <?php if($entry_gender =="m" ) { echo " checked";} ?>></td> </tr> <tr class="catcentralmini1"> <td >Nom</td> <td ><input name="nom" value="<?php echo $entry_lastname;?>" size="20" maxlength="20"></td> </tr> <tr> <td class="catcentralmini1">Prenom</td> <td class="catcentralmini1"><input name="prenom" value="<?php echo $entry_firstname;?>" size="20" maxlength="20"></td> </tr> <tr> <td class="catcentralmini1">Adresse</td> <td class="catcentralmini1"> <input name="adresse" value="<?php echo $entry_street_address;?>" size="20" maxlength="100"></td> </tr> <tr> <td class="catcentralmini1">&nbsp;</td> <td class="catcentralmini1"><input name="adresse2"></td> </tr> <tr> <td class="catcentralmini1">Code postal </td> <td class="catcentralmini1"><input name="cp" value="<?php echo $entry_postcode;?>" size="10" maxlength="5"></td> </tr> <tr> <td class="catcentralmini1">Ville</td> <td class="catcentralmini1"><input name="ville" value="<?php echo $entry_city;?>" size="20" maxlength="20"></td> </tr> <tr> <td align="right" class="catcentralmini1"><input type="hidden" name="cid" value="<?php echo $address_book_id<input type="hidden" name="s_etape" value="1"><input type="image" src="images_template/boutons_template/button_modifieradresse.gif" border="0" value="submit"></td> </tr> </table> </form> <?php break; } ?>
le truc c'est que j'execute l update une fois cela marche (Nombre d'enregistrements affectés : 1 ) je le fait une deuxieme fois dans phpmyadmin en changeant un parametre et la Nombre d'enregistrements affectés : 0 . et mon entry_gender au lieu d'etre à M ou F ( j'ai fait un echo desuus il ets bien renseigné ) est à 0 ....

Le probleme surement un truc tellement gros que je ne le vois pas donc si vous avez la patience de jete un coup d'oeuil à ce code merci d'avance :!:
Univers divided by 0 - cucumber error - reboot

Invité
Invité n'ayant pas de compte PHPfrance

24 mars 2005, 16:43

Un truc qui saute aux yeux :

Code : Tout sélectionner

if (isset($_POST['nom'])){ $nom = $_POST['nom']; } if (isset($_POST['gender'])){ echo $gender = $_POST['gender']; } if (isset($_POST['prenom'])){ $prenom = $_POST['prenom']; }
Enlève le echo.