error in where clause
Posted: Tue Nov 11, 2003 10:46 pm
have a function to select data from a mysql database with a join. (php)
I am having trouble in the where variable giving me a MYSQL error - "uknow column 'yes' in where clause". All is working correctly but when I add the active - column to the query i get the error.
The problem is that I do not want this part of the where clause to check between columns but to see if column p.active = "yes"... Is there a way that I can make the where clause detect this without referencing between the two tables while leaving the other two clauses functioning as part of this function?
Any Help would be muchly appreciated.
[/php_man]
I am having trouble in the where variable giving me a MYSQL error - "uknow column 'yes' in where clause". All is working correctly but when I add the active - column to the query i get the error.
The problem is that I do not want this part of the where clause to check between columns but to see if column p.active = "yes"... Is there a way that I can make the where clause detect this without referencing between the two tables while leaving the other two clauses functioning as part of this function?
Any Help would be muchly appreciated.
Code: Select all
<?php
// run function
$qid_p = get_products($id,$yes);
function get_products($category_id=0, $yes) {
/* get all the products under this category */
$qid = db_query("
SELECT
p.id
,p.name
,p.description
,p.price
,p.on_special
,p.image
,p.author
,p.isbn
,p.pages
,p.type
,p.in_stock
,p.active
,pc.category_id
FROM
products p
,products_categories pc
WHERE p.active = $yes
AND p.id = pc.product_id
AND pc.category_id = $category_id
");
return $qid;
}
?>