|
Bonsoir,
Tout d'abord mes excuses si je ne poste pas au bon endroit ni comme il faut.
Merci d'avance
Qui pourrait m'aider à corriger cette horreur? Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/local/apache/htdocs/sites/v/voyeaud.org/Travaux/Releves/BMS_NMD/Guignen/E/35127E3a.php on line 211
C'est un code qui marche sur d'autres pages sans problèmes. Si je change le nom de la table le problème se résoud partiellement.
Code à priori utile pour me dépanner:
//CONNEXION A LA BASE $mysql_id=mysql_connect($server,$user,$pwd);
// Sortir du script en cas de problème de connexion //au serveur. if(!$mysql_id){ echo "Problème de connexion à la base : ".mysql_errno().": ".mysql_error()."<br />"; exit; } // Récupération des éléments de recherches $nom=$_REQUEST['nom']; $prenom=$_REQUEST['prenom']; $j=$_REQUEST['j']; $nb_pages=$_REQUEST['nb_pages']; $ligne_debut=$_REQUEST['$ligne_debut']; $page=$_REQUEST['page']; $row=$_REQUEST['row'];
//SELECTION DE LA BASE mysql_select_db($base,$mysql_id);
//SELECTION DE LA TABLE $table = '35127E3';
//CONSTRUCTION DE LA CLAUSE 'WHERE' //if ($nom){ // Si un nom est inscrit dans le formulaire // $where=" WHERE Nom LIKE '%". $nom. "%' OR Nom_Pere LIKE '%". $nom. "%'OR Nom_Mere LIKE '%". $nom. "%'OR Nom_Parrain LIKE '%". $nom. "%'OR Nom_Marraine LIKE '%". $nom. "%'OR Presents LIKE '%". $nom. "%'"; // if ($prenom){ // Si le prénom est aussi renseigné // $where=" WHERE (Nom='". $nom."' AND Prenom LIKE '%".$prenom. "%') OR (Nom_Pere='". $nom."' AND Prenom_Pere LIKE '%".$prenom. "%') OR (Mere='". $nom."' AND Prenom_Mere LIKE '%".$prenom. "%') OR (Nom_Parrain='". $nom."' AND Prenom_Parrain LIKE '%".$prenom. "%') OR (Nom_Marraine='". $nom."' AND Prenom_Marraine LIKE '%".$prenom. "%')"; // } //} //else{ // Les deux champs sont vides //$where=""; //}
//CONSTRUCTION DE LA CLAUSE 'WHERE' if ($nom){ // Si un nom est inscrit dans le formulaire $where=" WHERE Nom='".$nom. "'"; if ($prenom){ // Si le prénom est aussi renseigné $where=" WHERE Nom='".$nom."' AND Prenom LIKE '%".$prenom. "%' "; } } else{ // Les deux champs sont vides $where=""; }
//CONSTRUCTION DE LA CLAUSE 'LIMIT' //Nombre d'enregistrements souhaités par page $nb_par_page=100;
if (!$page){ $ligne_debut=0; } else{ $page=$page-1; $ligne_debut=$page*$nb_par_page; }
$limit=" LIMIT ".$ligne_debut.", ".$nb_par_page;
//REQUETE SQL $qry="SELECT * FROM $table".$where.$limit; //echo $qry;
//EXECUTION DE LA REQUETE $result=mysql_query($qry);
$nb_pages=($nb_fiches_max/$nb_par_page); $nb_pages=ceil($nb_pages);
//CALCUL DU NOMBRE DE PAGES
if (!$nb_pages) { // Si le nb de pages n'a encore jamais été calculé
if ($nom){ $nb_fiches_max=mysql_num_rows($result); } //else{ // $qry2="SELECT * FROM $table"; //echo $qry2; //$result2=mysql_query($qry2); //$nb_fiches_max=mysql_num_rows($result2); //} $nb_pages=($nb_fiches_max/$nb_par_page); $nb_pages=ceil($nb_pages); }
// MESSAGE AU DESSUS DU TABLEAU if ($nb_fiches_max > 0){ //S'il y a au moins un résultat $page=$page+1; $msg= "page ".$page." sur ".$nb_pages." pour ".$nb_fiches_max." enregistrements"; //On affiche le nombre de pages sur le total } else{ $msg="Désolé, aucun enregistrement trouvé !"; //Sinon, on signale qu'il n'y a pas de résultats }
//DECLARATIONS DES FONCTIONS RIGHT ET LEFT QUI N'EXISTE PAS EN PHP ! function left($chaine,$num) { return substr($chaine,0,$num); }
function right($chaine,$num) { return substr($chaine,-$num); } ?>
<body> <h1 style="text-align: center">Transports de corps<br> Cote E3-18</h1> <div style="text-align: center;"> <!-- FORMULAIRE --> <div style="text-align: center;"> <form action= '35127E3a.php' method="post"> <table style="border:0px;"> <td style="border:0px;"><strong>NOM</strong></td> <td style="border:0px;"><input type="text" name="nom" value="<?php echo $nom?>"></td> <td style="border:0px;"><strong>Prénom</strong></td> <td style="border:0px;"><input type="text" name="prenom" value="<?php echo $prenom?>"></td> <td style="border:0px;"><input type="submit" name="submit" value="Rechercher"></td> </tr> </table> </form>
</div> <!-- FIN FORMULAIRE -->
<div style="text-align: center;"> <?php echo $msg."\n"; // On écrit le message au dessus du tableau ?>
<!-- EN-TÊTES DU TABLEAU --> <table class="result"> <tr> <td class="nom">Nom</td> <td class="prenom">Prénom</td> <td class="date">Date Décès</td> </tr> <!-- FIN EN-TÊTES DU TABLEAU -->
<!-- REMPLISSAGE DU TABLEAU --> <?php while($row=mysql_fetch_object($result)){ echo "<tr style=\"cursor: hand;\" onmouseover=\"this.style.backgroundColor='#6C81B9'\" onmouseout=\"this.style.backgroundColor = ''\" onclick=\"javascript:window.open('pop_35127E3_18.php?id=$row->id','popup','width=550,height=780,left=0,top=0,toolbar=no,menubar=no,resizable=no,scrollbars=yes');return(false);\">\n"; //TRAITEMENT DES AUTRES CHAMPS echo "<td>$row->Nom</a></td>\n"; echo "<td>$row->Prenom</td>\n"; echo "<td>$row->Date</td>\n"; echo "</tr>\n"; } ?> </table> <!-- FIN REMPLISSAGE DU TABLEAU -->
?>
</div>
<!-- LIENS VERS LES AUTRES PAGES --> <div class="pages"> <?php $i=0; while ($i <= $nb_pages-1): $j=$i+1; if ((!$nom) AND (!$prenom)){ echo "<span class=\"page\"><a href=\"35127E3a.php?page=".$j."&nb_pages=".$nb_pages."\">".$j."</a></span>\n"; } else if (($nom) AND ($prenom)) { echo "<span class=\"page\"><a href=\"35127E3a.php?page=".$j."&nb_pages=".$nb_pages."&nom=".$nom."&prenom=".$prenom."\">".$j."</a></span>\n"; } else{ echo "<span class=\"page\"><a href=\"35127E3a.php?page=".$j."&nb_pages=".$nb_pages."&nom=".$nom."\">".$j."</a></span>\n"; } $i++; endwhile; ?> |
|
Salut,
Quant tu as cette erreur, c'est que le résultat de ta requête n'a pas pu être traité, il faut que tu vérifies le nom de tes tables et de tes champs sur lesquels tu l'as construite.
@+ |