PDA

View Full Version : Why wont this work?


Jalrock
04-04-2003, 10:57 PM
<?php
include "store_include.php";
////----INDIVIDUAL PRODUCT VIEW ---------------------///
if ($prodid) {
$product = '';
$sql = $DB_site->query = "SELECT * FROM product WHERE prodid=$prodid";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);

$prodid = $myrow["prodid"];
$prodname = $myrow["prodname"];
$image = $myrow["image"];
$price = $myrow["price"];
$cost = $myrow["cost"];
$sellerusername = $myrow["username"];
eval("\$product .= \"".gettemplate("store_productbit")."\";");
////----END INDIVIDUAL PRODUCT VIEW ---------------------///
////----VIEW BY CATAGORY---------------------------------///
} elseif ($cat) {
$catbit = '';
$sql = $DB_site->query = "SELECT prodid,prodname,image,price,cost,username FROM product WHERE catid='$catid'";
$result = mysql_query($sql);
while ($myrow = mysql_fetch_array($result)) {

$prodid = $myrow["prodid"];
$prodname = $myrow["prodname"];
$image = $myrow["image"];
$price = $myrow["price"];
$cost = $myrow["cost"];
$sellerusername = $myrow["username"];

eval("\$catbit .= \"".gettemplate("store_catbit")."\";");
}
////----END VIEW BY CATAGORY---------------------------------///

}else{
$content = '';
$sql = $DB_site->query = "SELECT * FROM product";
$result = mysql_query($sql);
while ($myrow = mysql_fetch_array($result)) {

$prodid = $myrow["prodid"];
$prodname = $myrow["prodname"];
$image = $myrow["image"];
$price = $myrow["price"];
$cost = $myrow["cost"];
$sellerusername = $myrow["username"];

eval("\$content .= \"".gettemplate("store_contentbit")."\";");
}
}

eval("dooutput(\"".gettemplate('store_main')."\");");
?>


This is the error I get if you try to view by catagory.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/twins-cl/public_html/forum/store_index.php on line 23

mr e
04-05-2003, 06:36 PM
im pretty sure this doesn't work

$sql = $DB_site->query = "SELECT prodid,prodname,image,price,cost,username FROM product WHERE catid='$catid'";
$result = mysql_query($sql);


try this

$result = $DB_site->query("SELECT prodid,prodname,image,price,cost,username FROM product WHERE catid='$catid');