0

When I am trying to choose t1 column 1 and t2 column 2 from database, it won't echo it out, can anyone tell me if this line is wrong?

$query_category = "SELECT recipedia_categories.category_name, recipedia_recipies.category 
FROM recipedia_categories 
INNER JOIN category 
ON recipedia_categories.ID=recipedia_recipies.category_ID";
$result_category = $db->query($query_category);
while ($row_category = $result_category->fetch_assoc()) {
    $cat_name = $row_category['category_name'];
}

and in HTML I am using

<?=$cat_name;?>

When using the fetch_assoc it gives me an error

Fatal error: Call to a member function fetch_assoc() on boolean

I hope someone can tell me what's wrong here :)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
krunos
  • 163
  • 1
  • 9
  • 1
    `$result_category` is boolean and probably it is false. You can check with `var_dump($result_category)`. Probably there is something wrong with your SQL query. You can check the error with `echo $db->error`. (Assuming that you are using mysqli extension) – Ugur May 26 '15 at 23:54
  • 1
    I think $result_category is a boolean and not an object , check what $db->query($query_category) is returning . – jcromanu May 27 '15 at 02:53

0 Answers0