Is this SELECT statement right.

Each of the statements works when used alone but when I ad the UNION ALL or just the UNION statement something is going wrong. All the variables are preset and working. I have tested everything up to the SELECT statements.

PHP Code:

$sql="SELECT * FROM recipes WHERE Cat='$cat'and Eggs='$Eggs' and Fruitose='$Fruitose' and Gluten='$Gluten' and Lactose='$Lactose' and Nuts='$Nuts' and Soy='$Soy' and LowFat='$LowFat' and Diabetice='$Diabetice' and Vegan='$Vegan'
UNION ALL
SELECT * FROM recipes WHERE Cat='$cat'and Eggs='$Eggs2' and Fruitose='$Fruitose2' and Gluten='$Gluten2' and Lactose='$Lactose2' and Nuts='$Nuts2' and Soy='$Soy2' and LowFat='$LowFat2' and Diabetice='$Diabetice2' and Vegan='$Vegan2'";

$sql="SELECT * FROM recipes WHERE Cat='$cat' and Eggs='$Eggs' and Fruitose='$Fruitose' and Gluten='$Gluten' and Lactose='$Lactose' and Nuts='$Nuts' and Soy='$Soy' and LowFat='$LowFat' and Diabetice='$Diabetice' and Vegan='$Vegan'
UNION ALL
SELECT * FROM recipes WHERE Cat='$cat' and Eggs='$Eggs2' and Fruitose='$Fruitose2' and Gluten='$Gluten2' and Lactose='$Lactose2' and Nuts='$Nuts2' and Soy='$Soy2' and LowFat='$LowFat2' and Diabetice='$Diabetice2' and Vegan='$Vegan2'";

If this is the query, it looks to be fine... It must be your PHP thats wrong.

Um, you have to actually fetch the rows. The old MySQL functions you're using only return a resource, which you then have to pass to mysql_fetch_assoc() or the various other fetch functions.

Note that the mysql_() functions are obsolete since about a decade and have officially been deprecated, which means they'll be removed sooner or later. Time to switch to one of the contemporary database extensions.

Why canít I use certain words like "drop" as part of my Security Question answers?
There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

Why canít I use certain words like "drop" as part of my Security Question answers?
There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".