probleme de syntaxe
Posté : 16 juil. 2007, 17:30
Bonjour, j'espère être dans la bonne rubrique pour poster.....
J'ai un petit problème d'affichage avec un site en développement. J'avais le même type d'erreur sur certaines pages, le fait de changer la syntaxe des requêtes m'a fait disparaitre le message d'erreur du type suivant "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ..../index.php on line 126".
Voici donc la page qui s'affiche mal : http://www.laboiteaoutils.fr/bibliotheque/index.php
Voici mon fichier index.php (la ligne en gras étant normalement celle qui pose problème):
J'ai un petit problème d'affichage avec un site en développement. J'avais le même type d'erreur sur certaines pages, le fait de changer la syntaxe des requêtes m'a fait disparaitre le message d'erreur du type suivant "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ..../index.php on line 126".
Voici donc la page qui s'affiche mal : http://www.laboiteaoutils.fr/bibliotheque/index.php
Voici mon fichier index.php (la ligne en gras étant normalement celle qui pose problème):
[quote]<?
$id_site=1;
require_once("../include/class_page.inc.php");
$page=New P_atelier($id_site);
$page->P_biblio();
require_once($page->url_ref."include/class_bdd.inc.php");
require_once($page->url_ref."include/class_menu.inc.php");
require_once($page->url_ref."include/class_magasin.inc.php");
require_once($page->url_ref."include/class_biblio.inc.php");
$liste=New ListeChoixMagasin($id_site,$page->url_ref);
$menu=New Menu(1,5,$id_site,$page->url_ref);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$page->titre_fen?></title>
<?=$page->meta;?>
<link href="<?=$page->url_ref?><?=$page->style?>" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function PopContact()
{
var url="<?=$page->url_ref?>contact.php";
MM_openBrWindow(url,'PopContact','status=no,toolbar=no,scrollbars=auto,resizable=no,width=588,height=620');
}
function PopMention()
{
var url="<?=$page->url_ref?>mentions_legales.php";
MM_openBrWindow(url,'PopMention','status=no,toolbar=no,scrollbars=yes,resizable=no,width=608,height=620');
}
</script>
</head>
<body>
<table width="985" border="0" cellspacing="0" cellpadding="0">
<?
$page->BandeauHt();
echo"$page->bandeau_ht";
?>
<tr>
<td valign="top" class="background">
<table width="180" height="64" border="0" align="center" cellpadding="0" cellspacing="0" class="mag" >
<tr>
<form name="form2">
<td height="49" valign="top" align="center" class="TxtSelMag">
<div align="center" style="font-size:12px; color: #553403; padding-top:2px">Choisissez<br>votre magasin :</div>
<select name="menu2" onChange="MM_jumpMenu('parent',this,0)" class="magMenu">
<option selected>Cliquez ici</option>
<?
$contenuListe=$liste->Recherche();
echo"$contenuListe";
?>
</select>
</td>
</form>
</tr>
</table>
<br>
<?
echo"$menu->affiche_menu";
?>
</td>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td height="69" colspan="5" class="cadreVert">
<div class="vert2" style="font-size:32px; letter-spacing: 0.1em"><strong>BIBLIOTHEQUE</strong></div>
<span class="Txt16">Notre sélection d'ouvrages avec notre partenaire Amazon.fr</span>
</td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="cadreVert">
<tr align="center">
<td width="1%"><img src="<?=$page->url_ref?>images/spacer.gif" width="10" height="10"></td>
<td width="49%"> </td>
<td width="1%"><img src="<?=$page->url_ref?>images/spacer.gif" width="10" height="10"></td>
<td width="48%"> </td>
<td width="1%"><img src="<?=$page->url_ref?>images/spacer.gif" width="10" height="10"></td>
</tr>
<?
$biblio=New Biblio($id_site,$page->url_ref);
$result=$biblio->Liste();
$i=0;
$j=0;
$l1="";
$l2="";
$sep="<tr><td colspan=\"5\"> </td></tr>\n";
[b]while ($row=mysql_fetch_row($result))[/b]
{
$img=$page->url_ref.$row[2];
$img_on=$page->url_ref.$row[3];
$dim_img=getimagesize($img);
if ($i==0)
{
$l1.="<tr>\n
<td> </td>\n
<td valign=\"top\" align=\"center\" ><a href=\"$row[1]\" onMouseOver=\"MM_swapImage('img$j','','$img_on',0)\" onMouseOut=\"MM_swapImgRestore()\" target=\"_blank\"><img name=\"img$j\"src=\"$img\" width=\"$dim_img[0]\" height=\"$dim_img[1]\" border=\"0\"></a></td>\n
<td> </td>\n";
$l2.="<tr>\n
<td> </td>\n
<td valign=\"top\" align=\"center\" ><a href=\"$row[1]\" target=\"_blank\">$row[0]</a></td>\n
<td> </td>\n";
$i=1;
$comment=$biblio->FindComment($row[4]);
if ($comment!="")
{
$l1.="<td class=\"dGuideTxt\" valign=\"middle\" align=\"center\" >$comment</td>\n
<td> </td>\n
</tr>\n";
$l2.="<td class=\"dGuideTxt\" valign=\"middle\" align=\"center\" > </td>\n
<td> </td>\n
</tr>\n";
$i=0;
echo"$l2";
echo"$sep";
echo"$l1";
echo"$sep";
echo"$sep";
$l1="";
$l2="";
}
}
else
{
$l1.="<td class=\"\" valign=\"top\" align=\"center\"><a href=\"$row[1]\" onMouseOver=\"MM_swapImage('img$j','','$img_on',0)\" onMouseOut=\"MM_swapImgRestore()\" target=\"_blank\"><img name=\"img$j\"src=\"$img\" width=\"$dim_img[0]\" height=\"$dim_img[1]\" border=\"0\"></a></td>\n
<td> </td>\n
</tr>\n";
$l2.="<td class=\"\" valign=\"top\" align=\"center\"><a href=\"$row[1]\" target=\"_blank\">$row[0]</a></td>\n
<td> </td>\n
</tr>\n";
$i=0;
echo"$l2";
echo"$sep";
echo"$l1";
echo"$sep";
echo"$sep";
$l1="";
$l2="";
}
$j++;
}
?>
<tr>
<td colspan="5"> </td>
</tr>
</table>
</td>
<td valign="top" align="right">
<form method="get" action="http://www.amazon.fr/exec/obidos/external-search" target="main">
<table width="80%" border="0" cellspacing="0" cellpadding="0" class="cadreVert">
<tr>
<td class="dGuideTxt" align="center">
<input type=hidden name="mode" value="books-fr">
<p> Recherche <br>par mots clés<br>
<input type="text" name="keyword" size="10" value="">
<input type="hidden" name="tag" value="laboiteaout0a-21">
<input type="image" width="21" height="21" border="0" value="Go" name="Go" src="<?=$page->url_ref?>images/bibliotheque/go-button.gif" align="absmiddle">
</td>
</tr>
<tr><td> </td></tr>
<tr >
<td bgcolor="#000000" align="center"> <a href="http://www.amazon.fr/exec/obidos/redirect-home?site=amazon&tag=laboiteaout0a-21" target=main><img width="126" height="32" src="<?=$page->url_ref?>images/bibliotheque/126X32-b-logo.gif" border="0" hspace="0" vspace="0" alt=""></a> </td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="3"><img src="<?=$page->url_ref?>images/spacer.gif" width="1" height="8"></td>
</tr>
</table>
</body>
</html>[/quote]
Et le fichier include s'y rattachant :Merci d'avance de l'aide que vous pourrez m'apporter.<? Class Biblio { var $id_site; var $bdd; var $url_ref; var $serviceList; function Biblio($id_site,$url_ref) { $this->id_site=$id_site; $this->url_ref=$url_ref; $this->bdd=New Bdd(); return($this); } function Liste() { $sql="SELECT titre,url,img,img_on,id FROM biblio WHERE (etat=0) AND id_site = '$this->id_site' ORDER BY position"; $result=$this->bdd->ExecuteSql($sql); return($result); } function ListeAdmin() { $sql="SELECT * FROM biblio WHERE id_site = '$this->id_site' ORDER BY position"; $result=$this->bdd->ExecuteSql($sql); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $rows[] = $row; } } $this->serviceList = $rows; return($rows); } function loadMain($id) { $sql="SELECT * FROM biblio WHERE id = '$id' ORDER BY position"; $result=$this->bdd->ExecuteSql($sql); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $rows = $row; } } return($rows); } function delete($id) { $sql = "delete from biblio_comment where id_biblio = '$id'"; $this->bdd->ExecuteSql($sql); $sql = "delete from biblio where id = '$id'"; $this->bdd->ExecuteSql($sql); } function setService($id, $arr) { if (isset($arr['titre'])) { $vv['titre'] = $arr['titre']; } if (isset($arr['url'])) { $vv['url'] = $arr['url']; } if (isset($arr['img'])) { $vv['img'] = $arr['img']; } if (isset($arr['img_on'])) { $vv['img_on'] = $arr['img_on']; } if (isset($arr['etat'])) { $vv['etat'] = $arr['etat']; } if (isset($arr['content'])) { $vv['content'] = $arr['content']; } $vv['id'] = $id; $this->serviceList = $vv; } function store() { $serviceList = &$this->serviceList; foreach ($serviceList as $k => &$v) { $v = mysql_escape_string($v); } if ($serviceList['id'] == -1) { $maxOrderR = $this->bdd->ExecuteSql("SELECT max(`position`) as mmx FROM biblio WHERE id_site = '$this->id_site' "); $maxOrder = mysql_fetch_array($maxOrderR, MYSQL_ASSOC); $serviceList['position'] = (int)$maxOrder['mmx'] + 1; $query = " insert into biblio (titre, url, img, img_on, position, etat, id_site) values ('$serviceList[titre]', '$serviceList[url]', '$serviceList[img]', '$serviceList[img_on]', '$serviceList[position]', '$serviceList[etat]', '$this->id_site' ) "; $serviceList['id'] = $this->bdd->ExecuteSqlID($query, 'biblio'); $query = " insert into biblio_comment (id_biblio, comment) values ('$serviceList[id]', '$serviceList[content]') "; $this->bdd->ExecuteSql($query); } else { $query = " update biblio set titre = '$serviceList[titre]', url = '$serviceList[url]', img = '$serviceList[img]', img_on = '$serviceList[img_on]', etat = '$serviceList[etat]' where id = '$serviceList[id]' "; $this->bdd->ExecuteSql($query); $query = " update biblio_comment set comment = '$serviceList[content]' where id_biblio = '$serviceList[id]' "; $this->bdd->ExecuteSql($query); } return $serviceList['id']; } function FindComment($id_biblio) { $sql="SELECT comment FROM biblio_comment WHERE id_biblio=$id_biblio"; $result=$this->bdd->ExecuteSql($sql); $row=mysql_fetch_row($result); return($row[0]); } } ?>