probleme avec echo

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : probleme avec echo

par stefanelle » 26 mars 2009, 11:43

merci pour votre aide je viens de trouver c est a cause de ça

Code : Tout sélectionner

if (isset($_POST['ok']))
en fait il manque une majuscule à OK

Code : Tout sélectionner

if (isset($_POST['Ok']))

par julian » 26 mars 2009, 10:45

Pourquoi tu as <br>...</br> dans ton HTML ?

Sinon juste après tes requêtes, tu peux faire :
var_dump($req2);
var_dump($req3);

par Aureusms » 26 mars 2009, 10:35

Pourquoi ne pas utiliser empty() ? Si $req2 est non vide :...
if(!empty($req2))


{
echo ("L'insertion a été correctement effectuée") ;
echo '<br><a href="cat-haa_modif.php">Retour </a></br>';
}

if(!empty($req3))


{
echo ("Suppression ok") ;
echo '<br><a href="cat-haa_modif.php">Retour</a></br>';
}

par stefanelle » 26 mars 2009, 09:47

bah ce qui est bizarre c est que les actions demandées update delete select ... marche nickel c est juste l'affichage de l'echo ...

comment je peux tester sinon ?

par julian » 26 mars 2009, 09:33

Vérifies que tes requêtes ont bien été exécutées, car s'il ne rentrent pas dans la condition, c'est qu'il y a une erreur à l'exécution.

par stefanelle » 26 mars 2009, 08:48

Merci pour ton aide

j'y avis pensé et j'ai testé avec

Code : Tout sélectionner

if($req2) { echo ("L'insertion a été correctement effectuée") ; echo '<br><a href="cat-haa_modif.php">Retour </a></br>'; } if($req3) { echo ("Suppression ok") ; echo '<br><a href="cat-haa_modif.php">Retour</a></br>'; }
ca ne marche toujours pas .... :(

par Patriboom » 26 mars 2009, 04:52

Ton code te renverra toujours le message inséré dans la condition (if(isset($req3)) car la valeur sera toujours définie, que le résultat soit bon ou pas. Si le résultat est bon, tu obtiendras $req3=tableau à exploiter via mysql_fetch_ autrement $req3=false.

Ce que tu dois vérifier ce n'est donc pas si la variable est définie, mais si elle est vraie ou fausse,
ton if doit donc être if($req2) { .... } et if($req3) { .... }

probleme avec echo

par stefanelle » 26 mars 2009, 01:34

Bonjour,

voila j ai un fichier hp qui fait bien ce que je veux le problème c'est que j ai fait 3 if { echo ... }

mais aucun ne prend en compte la condition

je ne comprend pas pourquoi

voici mon code

je mets en gras les zones concernées

Merciiii

Code : Tout sélectionner

<?php include ('cat-haa/config.php'); include ('cat-haa/connexion.php'); if (isset($_POST['ok'])) { $sql2= "UPDATE contenu SET reference='".$_POST['reference']."', artiste='".$_POST['artiste']."',album='".$_POST ['album']."',format='".$_POST['format']."' WHERE id='".$_POST['id']."'" ; $req2= mysql_query($sql2) or die('Erreur SQL !'.$sql2.'<br>'.mysql_error()); } if (isset($_POST['suppr'])) { $sql3= "delete from contenu WHERE id='".$_POST['id']."'" ; $req3= mysql_query($sql3) or die('Erreur SQL !'.$sql3.'<br>'.mysql_error()); } ?> <head> <link rel="stylesheet" type="text/css" href="../cat-haa/style-cat.css"> <!--[if IE]> <link rel="stylesheet" type="text/css" href="../cat-haa/style-cat-ie6.css"> <![endif]--> </head> <body link="#000000" vlink="#FFFFFF" alink="#FFFFFF"> <div id="body-cat"> <div id="menu-container-cat"> <div id="menu-container-cat1"><b> <a href="cat-haa.php?lettre=[0-9]" class="active"><span class="text-cat">0-9</span></a> | <a href="cat-haa.php?lettre=A" target="_self"><span class="text-cat">A</span></a> | <a href="cat-haa.php?lettre=B" target="_self"><span class="text-cat">B</span></a> | <a href="cat-haa.php?lettre=C" target="_self"><span class="text-cat">C</span></a> | <a href="cat-haa.php?lettre=D" target="_self"><span class="text-cat">D</span></a> | <a href="cat-haa.php?lettre=E" target="_self"><span class="text-cat">E</span></a> | <a href="cat-haa.php?lettre=F" target="_self"><span class="text-cat">F</span></a> | <a href="cat-haa.php?lettre=G" target="_self"><span class="text-cat">G</span></a> | <a href="cat-haa.php?lettre=H" target="_self"><span class="text-cat">H</span></a> | <a href="cat-haa.php?lettre=I" target="_self"><span class="text-cat">I</span></a> | <a href="cat-haa.php?lettre=J" target="_self"><span class="text-cat">J</span></a> | <a href="cat-haa.php?lettre=K" target="_self"><span class="text-cat">K</span></a> | <a href="cat-haa.php?lettre=L" target="_self"><span class="text-cat">L</span></a> | <a href="cat-haa.php?lettre=M" target="_self"><span class="text-cat">M</span></a> | <a href="cat-haa.php?lettre=N" target="_self"><span class="text-cat">N</span></a> | <a href="cat-haa.php?lettre=O" target="_self"><span class="text-cat">O</span></a> | <a href="cat-haa.php?lettre=P" target="_self"><span class="text-cat">P</span></a> | <a href="cat-haa.php?lettre=Q" target="_self"><span class="text-cat">Q</span></a> | <a href="cat-haa.php?lettre=R" target="_self"><span class="text-cat">R</span></a> | <a href="cat-haa.php?lettre=S" target="_self"><span class="text-cat">S</span></a> | <a href="cat-haa.php?lettre=T" target="_self"><span class="text-cat">T</span></a> | <a href="cat-haa.php?lettre=U" target="_self"><span class="text-cat">U</span></a> | <a href="cat-haa.php?lettre=V" target="_self"><span class="text-cat">V</span></a> | <a href="cat-haa.php?lettre=W" target="_self"><span class="text-cat">W</span></a> | <a href="cat-haa.php?lettre=X" target="_self"><span class="text-cat">X</span></a> | <a href="cat-haa.php?lettre=Y" target="_self"><span class="text-cat">Y</span></a> | <a href="cat-haa.php?lettre=Z" target="_self"><span class="text-cat">Z</span></a></b> </div> <div id="menu-container-cat2"> <?php $rq = "SELECT DISTINCT nom_label FROM label ORDER BY nom_label"; $result = mysql_query($rq) or die ("Exécution de la requête impossible"); echo "<form action='cat-haa2.php' method='post'> <select name='nom_label'>"; while ($liste=mysql_fetch_array($result)) { extract($liste); echo "<option value='$nom_label'>$nom_label\n"; } echo " </select>\n"; echo "<input type='submit'"."value='Go'></form>\n"; ?> </div> </div> <?php [b]if(isset($req2)) { echo ("L'insertion a été correctement effectuée") ; echo '<br><a href="cat-haa_modif.php">Retour </a></br>'; }[/b] [b]if(isset($req3)) { echo ("Suppression ok") ; echo '<br><a href="cat-haa_modif.php">Retour</a></br>'; }[/b] echo '<table> <tr> <th>id</th> <th>Label</th> <th>Référence</th> <th>Artiste</th> <th>Album</th> <th>Format</th> <th>Modifier</th> <th>supprimer</th> </tr>'; // paramètre reçu désignant le critère du nom du label recherché $param1 = mysql_real_escape_string($_GET['lettre']); // $sql = "SELECT * FROM label INNER JOIN contenu ON contenu.id_label = label.id_label Where nom_label REGEXP '^$param1' order by nom_label, reference; "; $req = mysql_query($sql); while ($resultat = mysql_fetch_array($req)) { echo '<tr>'; echo '<td>'.$resultat['id'].'</td>'; echo '<td>'.$resultat['nom_label'].'</td>'; echo '<td>'.$resultat['reference'].'</td>'; echo '<td>'.$resultat['artiste'].'</td>'; echo '<td>'.$resultat['album'].'</td>'; echo '<td>'.$resultat['format'].'</td>'; echo '<td><a href="modifier.php?id='.$resultat['id'].'"><font color="#ffffff"><u>Modifier</u></font></a></td>'; echo '<td><a href="supprimer.php?id='.$resultat['id'].'"><font color="#ffffff"><u>Supprimer</u></font></a></td>'; echo '</tr>'; } echo '</table>'; [b]$var = $resultat; if($var == null){ echo "Aucune référence trouvée"; } [/b] ?> <div id="cat-footer"></div> </div> </body></html> <?php mysql_close(); ?>