Php mysql query

I’ve made this little query in php:


$category = 1;

$query = "SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM Products WHERE CategoryID='$category'";

The problem is when I write it like that I won’t get any output in my mysql_fetch_array… but if I write it like:


$query = "SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM Products WHERE CategoryID=1";

so I don’t get the ID from the variable… then it shows all the items with categoryID 1…

Can any see what I’m doing wrong here :S have been sitting with it for some hours now :frowning:

Have you checked to make sure that $category actually has something in it?

Add:


var_dump($category);

somewhere above that and check what it outputs.

get this returned:

int(1)