I have spent hours trying to follow all the great advice of coders here trying to fix this problem. I KNOW this is a duplicate of 50 other posts, but cannot find any code close enough to mine to fix it. I am new to PHP and have an old eCommerce cart on a site that cannot be updated. Please don't flame me for my ignorance. Can someone give me the exact instructions on how to fix this. Thanks in advance!
I just copied the code directly from the file. I did not add all the @.
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/xxx /public_html/vsadmin/inc/mod/text.php on line 18
<?php
$cat = @$_GET['cat']; // Current Category ID
if(trim(@$_GET['cat'])!='') $theid = unstripslashes(@$_GET['cat']);
if(@$explicitid!='' && is_numeric(@$explicitid))
$theid=@$explicitid;
elseif(@$usecategoryname && $theid!=''){
$sSQL = 'SELECT sectionID FROM sections WHERE '.getlangid('sectionName',256)."='".escape_string($theid)."'";
$result = mysql_query($sSQL) or print(mysql_error());
if($rs=mysql_fetch_assoc($result)){ $catname=$theid; $theid=$rs['sectionID']; }
mysql_free_result($result);
}
$cat = $theid;
$queryrank="SELECT * from sections WHERE sectionID= '" . $cat . "' ";
$resultrank=mysql_query($queryrank);
?>
<?php
while ($sSQL =mysql_fetch_array ($resultrank))//<< line 18
{
$text = $sSQL['cattext'];
$html = $sSQL['cathtml'];
$optiom = $sSQL['catoption'];
if($sSQL['catoption']==1) {print "$text ";}
else print "$html";
}
?>
The only mysql_fetch_array
I see in your code is
while ($sSQL =mysql_fetch_array ($resultrank) )
So, $resultrank=mysql_query($queryrank);
must result in false
.
Ergo, your query $queryrank="SELECT * from sections WHERE sectionID= '" . $cat . "' ";
throws an error.
echo the mysql_error and you know what's wrong.
And, if you can, STOP using mysql-functions, they are depricated. Use mysqli or PDO instead.