mysql and php -- SQL: SELECT error
Posted by: nascent
Posted on: 2006-01-23 12:13:00
I'm having a problem and hope someone can help me. I have a page that keeps throwing the error below. It is a page that autopopulates a products "main" page which then has links to the various categories.
I finally set everything up on a different server entirely than my DH one and all works perfectly well on it, but on DH, the following error occurs.
I'm running apache as a module and not as cgi. (This is the same on both servers.)
Is there any hope of getting this to work on DH, or should I bite it and take this site elsewhere?
« Execution of a query to the database failed »
SQL: SELECT `061rc3`.etomite_product_log.prd_cat_id, `061rc3`.etomite_product_log.prd_id as item, `061rc3`.etomite_product_log.prd_name as call, `061rc3`.etomite_product_category.cat_name as name, `061rc3`.etomite_product_category.cat_page as page, max(`061rc3`.etomite_product_log.prd_dts) WHERE `061rc3`.etomite_product_log.prd_rem is null GROUP BY `061rc3`.etomite_product_log.prd_cat_id ORDER BY `061rc3`.etomite_product_category.cat_name ASC ;
and this is the code:
$pageid = $etomite->documentIdentifier;
$count = 0;
$output = '<table cellspacing=0 border=0 align=center width=90%><tr valign=top>'; // open table
# select latest entry based on settings above
$DbPre = $this->dbConfig['dbase'].".".$this->dbConfig['table_prefix'];
$t1 = $DbPre."product_log";
$t2 = $DbPre."product_category";
$sql = "SELECT $t1.prd_cat_id, $t1.prd_id as item, $t1.prd_name as call,
$t2.cat_name as name, $t2.cat_page as page, max($t1.prd_dts)
WHERE $t1.prd_rem is null GROUP BY $t1.prd_cat_id
ORDER BY $t2.cat_$sortBy $sortHow ;";
$result = $this->dbQuery($sql);
$rs = array();
for($i=0;$i<@$this->recordCount($result);$i++) {
array_push($rs,@$this->fetchRow($result));
}
# Display the existing entries in table format
if(count($rs) > 0) {
foreach($rs as $row) {
$count++;
$output .= "<td width=33%><a href=[~".$row['page']."~]>".$row['name'];
$output .= "<br/><img src=".$path_to_gal.$tmb_pre.$row['item'].".jpg alt="".$row['item'].": ".$row['call'].""></a></td>";
if ($count % $perrow == 0)
{ $output .= "</tr><tr valign=top>"; }
}
$left = count($rs) % $perrow;
if ($left == 0) {
for ($i = 1 ; $i <= $perrow ; $i++) {
$output .= "<td></td>"; }
} else {
for ($i = 0 ; $i <= $left ; $i++) {
$output .= "<td></td>"; }
}
$output .= "</tr>";
}
else
{ $output .= "There are currently no products in the set you requested.
Please try different filter options.";
}
$output .= "</table>";
return $output;