I've just been told that a query is too long and doesn't end but I don't understand what that means or how to rectify it?
This is the query I'm using (which I do admit is a large query but I need to get all of the info in it)
$sql_select = "SELECT * "; $sql_from = " FROM feeds, product_categories_map, type, source, sweeteners, flavour, ingredients, dietary, shipping, merchant WHERE feeds.enabled=1 and feeds.stock=1 and feeds.deleted=0 and feeds.brand_name=shipping.merchant and shipping.country_id=".dbstr( $_POST['country'] )." AND ( product_feed_id != 1 ";$sql_group = " GROUP BY feeds.product_name";$order=$_POST['order'];if ($_POST['order']<>""){ $sql_orderby = " ORDER BY feeds.$order ASC"; } else {$sql_orderby = " ORDER BY feeds.product_name DESC";}//$sql_orderby = " ORDER BY feeds.price ASC";if ($_POST['muscle']<>""){ $sql_where .= " OR category_id=1 "; } if ($_POST['performance']<>""){ $sql_where .= " OR category_id=2 "; } if ($_POST['diet']<>""){ $sql_where .= " OR category_id=3 "; } if ($_POST['lean']<>""){ $sql_where .= " OR category_id=4 "; } if ($_POST['energy']<>""){ $sql_where .= " OR category_id=5 "; } if ($_POST['health']<>""){ $sql_where .= " OR category_id=6 "; } if ($_POST['type_1']<>""){ $sql_where .= " OR type_id=1 "; } if ($_POST['type_2']<>""){ $sql_where .= " OR type_id=2 "; } if ($_POST['type_3']<>""){ $sql_where .= " OR type_id=3 "; } if ($_POST['type_4']<>""){ $sql_where .= " OR type_id=4 "; } if ($_POST['type_5']<>""){ $sql_where .= " OR type_id=5 "; } if ($_POST['type_6']<>""){ $sql_where .= " OR type_id=6 "; } if ($_POST['type_7']<>""){ $sql_where .= " OR type_id=7 "; } if ($_POST['type_8']<>""){ $sql_where .= " OR type_id=8 "; } if ($_POST['type_9']<>""){ $sql_where .= " OR type_id=9 "; } if ($_POST['type_10']<>""){ $sql_where .= " OR type_id=10 "; } if ($_POST['type_11']<>""){ $sql_where .= " OR type_id=11 "; } if ($_POST['type_12']<>""){ $sql_where .= " OR type_id=12 "; } if ($_POST['type_13']<>""){ $sql_where .= " OR type_id=13 "; } if ($_POST['type_14']<>""){ $sql_where .= " OR type_id=14 "; } if ($_POST['type_15']<>""){ $sql_where .= " OR type_id=15 "; } if ($_POST['type_16']<>""){ $sql_where .= " OR type_id=16 "; } if ($_POST['type_17']<>""){ $sql_where .= " OR type_id=17 "; } if ($_POST['type_18']<>""){ $sql_where .= " OR type_id=18 "; } if ($_POST['type_19']<>""){ $sql_where .= " OR type_id=19 "; } if ($_POST['type_20']<>""){ $sql_where .= " OR type_id=20 "; } if ($_POST['source_1']<>""){ $sql_where .= " OR source_id=1 "; } if ($_POST['source_2']<>""){ $sql_where .= " OR source_id=2 "; } if ($_POST['source_3']<>""){ $sql_where .= " OR source_id=3 "; } if ($_POST['source_4']<>""){ $sql_where .= " OR source_id=4 "; } if ($_POST['source_5']<>""){ $sql_where .= " OR source_id=5 "; } if ($_POST['source_6']<>""){ $sql_where .= " OR source_id=6 "; } if ($_POST['source_7']<>""){ $sql_where .= " OR source_id=7 "; } if ($_POST['source_8']<>""){ $sql_where .= " OR source_id=8 "; } if ($_POST['source_9']<>""){ $sql_where .= " OR source_id=9 "; } if ($_POST['source_10']<>""){ $sql_where .= " OR source_id=10 "; } if ($_POST['source_11']<>""){ $sql_where .= " OR source_id=11 "; } if ($_POST['source_12']<>""){ $sql_where .= " OR source_id=12 "; } if ($_POST['source_13']<>""){ $sql_where .= " OR source_id=13 "; } if ($_POST['source_14']<>""){ $sql_where .= " OR source_id=14 "; } if ($_POST['source_15']<>""){ $sql_where .= " OR source_id=15 "; } if ($_POST['source_16']<>""){ $sql_where .= " OR source_id=16 "; } if ($_POST['source_17']<>""){ $sql_where .= " OR source_id=17 "; } if ($_POST['source_18']<>""){ $sql_where .= " OR source_id=18 "; } if ($_POST['source_19']<>""){ $sql_where .= " OR source_id=19 "; } if ($_POST['source_20']<>""){ $sql_where .= " OR source_id=20 "; } if ($_POST['sweeteners_1']<>""){ $sql_where .= " OR sweeteners_id=1 "; } if ($_POST['sweeteners_2']<>""){ $sql_where .= " OR sweeteners_id=2 "; } if ($_POST['sweeteners_3']<>""){ $sql_where .= " OR sweeteners_id=3 "; } if ($_POST['sweeteners_4']<>""){ $sql_where .= " OR sweeteners_id=4 "; } if ($_POST['sweeteners_5']<>""){ $sql_where .= " OR sweeteners_id=5 "; } if ($_POST['sweeteners_6']<>""){ $sql_where .= " OR sweeteners_id=6 "; } if ($_POST['sweeteners_7']<>""){ $sql_where .= " OR sweeteners_id=7 "; } if ($_POST['sweeteners_8']<>""){ $sql_where .= " OR sweeteners_id=8 "; } if ($_POST['sweeteners_9']<>""){ $sql_where .= " OR sweeteners_id=9 "; } if ($_POST['sweeteners_10']<>""){ $sql_where .= " OR sweeteners_id=10 "; } if ($_POST['sweeteners_11']<>""){ $sql_where .= " OR sweeteners_id=11 "; } if ($_POST['sweeteners_12']<>""){ $sql_where .= " OR sweeteners_id=12 "; } if ($_POST['sweeteners_13']<>""){ $sql_where .= " OR sweeteners_id=13 "; } if ($_POST['sweeteners_14']<>""){ $sql_where .= " OR sweeteners_id=14 "; } if ($_POST['sweeteners_15']<>""){ $sql_where .= " OR sweeteners_id=15 "; } if ($_POST['sweeteners_16']<>""){ $sql_where .= " OR sweeteners_id=16 "; } if ($_POST['sweeteners_17']<>""){ $sql_where .= " OR sweeteners_id=17 "; } if ($_POST['sweeteners_18']<>""){ $sql_where .= " OR sweeteners_id=18 "; } if ($_POST['sweeteners_19']<>""){ $sql_where .= " OR sweeteners_id=19 "; } if ($_POST['sweeteners_20']<>""){ $sql_where .= " OR sweeteners_id=20 "; } if ($_POST['flavour_1']<>""){ $sql_where .= " OR flavour_id=1 "; } if ($_POST['flavour_2']<>""){ $sql_where .= " OR flavour_id=2 "; } if ($_POST['flavour_3']<>""){ $sql_where .= " OR flavour_id=3 "; } if ($_POST['flavour_4']<>""){ $sql_where .= " OR flavour_id=4 "; } if ($_POST['flavour_5']<>""){ $sql_where .= " OR flavour_id=5 "; } if ($_POST['flavour_6']<>""){ $sql_where .= " OR flavour_id=6 "; } if ($_POST['flavour_7']<>""){ $sql_where .= " OR flavour_id=7 "; } if ($_POST['flavour_8']<>""){ $sql_where .= " OR flavour_id=8 "; } if ($_POST['flavour_9']<>""){ $sql_where .= " OR flavour_id=9 "; } if ($_POST['flavour_10']<>""){ $sql_where .= " OR flavour_id=10 "; } if ($_POST['flavour_11']<>""){ $sql_where .= " OR flavour_id=11 "; } if ($_POST['flavour_12']<>""){ $sql_where .= " OR flavour_id=12 "; } if ($_POST['flavour_13']<>""){ $sql_where .= " OR flavour_id=13 "; } if ($_POST['flavour_14']<>""){ $sql_where .= " OR flavour_id=14 "; } if ($_POST['flavour_15']<>""){ $sql_where .= " OR flavour_id=15 "; } if ($_POST['flavour_16']<>""){ $sql_where .= " OR flavour_id=16 "; } if ($_POST['flavour_17']<>""){ $sql_where .= " OR flavour_id=17 "; } if ($_POST['flavour_18']<>""){ $sql_where .= " OR flavour_id=18 "; } if ($_POST['flavour_19']<>""){ $sql_where .= " OR flavour_id=19 "; } if ($_POST['flavour_20']<>""){ $sql_where .= " OR flavour_id=20 "; } if ($_POST['ingredients_1']<>""){ $sql_where .= " OR ingredients_id=1 "; } if ($_POST['ingredients_2']<>""){ $sql_where .= " OR ingredients_id=2 "; } if ($_POST['ingredients_3']<>""){ $sql_where .= " OR ingredients_id=3 "; } if ($_POST['ingredients_4']<>""){ $sql_where .= " OR ingredients_id=4 "; } if ($_POST['ingredients_5']<>""){ $sql_where .= " OR ingredients_id=5 "; } if ($_POST['ingredients_6']<>""){ $sql_where .= " OR ingredients_id=6 "; } if ($_POST['ingredients_7']<>""){ $sql_where .= " OR ingredients_id=7 "; } if ($_POST['ingredients_8']<>""){ $sql_where .= " OR ingredients_id=8 "; } if ($_POST['ingredients_9']<>""){ $sql_where .= " OR ingredients_id=9 "; } if ($_POST['ingredients_10']<>""){ $sql_where .= " OR ingredients_id=10 "; } if ($_POST['ingredients_11']<>""){ $sql_where .= " OR ingredients_id=11 "; } if ($_POST['ingredients_12']<>""){ $sql_where .= " OR ingredients_id=12 "; } if ($_POST['ingredients_13']<>""){ $sql_where .= " OR ingredients_id=13 "; } if ($_POST['ingredients_14']<>""){ $sql_where .= " OR ingredients_id=14 "; } if ($_POST['ingredients_15']<>""){ $sql_where .= " OR ingredients_id=15 "; } if ($_POST['ingredients_16']<>""){ $sql_where .= " OR ingredients_id=16 "; } if ($_POST['ingredients_17']<>""){ $sql_where .= " OR ingredients_id=17 "; } if ($_POST['ingredients_18']<>""){ $sql_where .= " OR ingredients_id=18 "; } if ($_POST['ingredients_19']<>""){ $sql_where .= " OR ingredients_id=19 "; } if ($_POST['ingredients_20']<>""){ $sql_where .= " OR ingredients_id=20 "; } if ($_POST['dietary_1']<>""){ $sql_where .= " OR dietary_id=1 "; } if ($_POST['dietary_2']<>""){ $sql_where .= " OR dietary_id=2 "; } if ($_POST['dietary_3']<>""){ $sql_where .= " OR dietary_id=3 "; } if ($_POST['dietary_4']<>""){ $sql_where .= " OR dietary_id=4 "; } if ($_POST['dietary_5']<>""){ $sql_where .= " OR dietary_id=5 "; } if ($_POST['dietary_6']<>""){ $sql_where .= " OR dietary_id=6 "; } if ($_POST['dietary_7']<>""){ $sql_where .= " OR dietary_id=7 "; } if ($_POST['dietary_8']<>""){ $sql_where .= " OR dietary_id=8 "; } if ($_POST['dietary_9']<>""){ $sql_where .= " OR dietary_id=9 "; } if ($_POST['dietary_10']<>""){ $sql_where .= " OR dietary_id=10 "; } if ($_POST['dietary_11']<>""){ $sql_where .= " OR dietary_id=11 "; } if ($_POST['dietary_12']<>""){ $sql_where .= " OR dietary_id=12 "; } if ($_POST['dietary_13']<>""){ $sql_where .= " OR dietary_id=13 "; } if ($_POST['dietary_14']<>""){ $sql_where .= " OR dietary_id=14 "; } if ($_POST['dietary_15']<>""){ $sql_where .= " OR dietary_id=15 "; } if ($_POST['dietary_16']<>""){ $sql_where .= " OR dietary_id=16 "; } if ($_POST['dietary_17']<>""){ $sql_where .= " OR dietary_id=17 "; } if ($_POST['dietary_18']<>""){ $sql_where .= " OR dietary_id=18 "; } if ($_POST['dietary_19']<>""){ $sql_where .= " OR dietary_id=19 "; } if ($_POST['dietary_20']<>""){ $sql_where .= " OR dietary_id=20 "; } $sql_where .= ") ";if ($_POST['muscle']<>"" || $_POST['performance']<>"" || $_POST['diet']<>"" || $_POST['lean']<>"" || $_POST['energy']<>"" || $_POST['health']<>""){$sql_end .= " AND feeds.product_feed_id = product_categories_map.product_id "; } if ($_POST['type_2']<>"" || $_POST['type_3']<>"" || $_POST['type_4']<>"" || $_POST['type_5']<>"" || $_POST['type_6']<>"" || $_POST['type_7']<>"" || $_POST['type_8']<>"" || $_POST['type_9']<>"" || $_POST['type_10']<>"" || $_POST['type_11']<>"" || $_POST['type_12']<>"" || $_POST['type_13']<>"" || $_POST['type_14']<>"" || $_POST['type_15']<>"" || $_POST['type_16']<>"" || $_POST['type_17']<>"" || $_POST['type_18']<>"" || $_POST['type_19']<>"" || $_POST['type_20']<>""){$sql_end .= " AND feeds.product_feed_id = type.product_id "; } if ($_POST['source_1']<>"" || $_POST['source_2']<>"" || $_POST['source_3']<>"" || $_POST['source_4']<>"" || $_POST['source_5']<>"" || $_POST['source_6']<>"" || $_POST['source_7']<>"" || $_POST['source_8']<>"" || $_POST['source_9']<>"" || $_POST['source_10']<>"" || $_POST['source_11']<>"" || $_POST['source_12']<>"" || $_POST['source_13']<>"" || $_POST['source_14']<>"" || $_POST['source_15']<>"" || $_POST['source_16']<>"" || $_POST['source_17']<>"" || $_POST['source_18']<>"" || $_POST['source_19']<>"" || $_POST['source_20']<>""){ $sql_end .= " AND feeds.product_feed_id = source.product_id "; } if ($_POST['sweeteners_1']<>"" || $_POST['sweeteners_2']<>"" || $_POST['sweeteners_3']<>"" || $_POST['sweeteners_4']<>"" || $_POST['sweeteners_5']<>"" || $_POST['sweeteners_6']<>"" || $_POST['sweeteners_7']<>"" || $_POST['sweeteners_8']<>"" || $_POST['sweeteners_9']<>"" || $_POST['sweeteners_10']<>"" || $_POST['sweeteners_11']<>"" || $_POST['sweeteners_12']<>"" || $_POST['sweeteners_13']<>"" || $_POST['sweeteners_14']<>"" || $_POST['sweeteners_15']<>"" || $_POST['sweeteners_16']<>"" || $_POST['sweeteners_17']<>"" || $_POST['sweeteners_18']<>"" || $_POST['sweeteners_19']<>"" || $_POST['sweeteners_20']<>""){ $sql_end .= " AND feeds.product_feed_id = sweeteners.product_id "; } if ($_POST['flavour_1']<>"" || $_POST['flavour_2']<>"" || $_POST['flavour_3']<>"" || $_POST['flavour_4']<>"" || $_POST['flavour_5']<>"" || $_POST['flavour_6']<>"" || $_POST['flavour_7']<>"" || $_POST['flavour_8']<>"" || $_POST['flavour_9']<>"" || $_POST['flavour_10']<>"" || $_POST['flavour_11']<>"" || $_POST['flavour_12']<>"" || $_POST['flavour_13']<>"" || $_POST['flavour_14']<>"" || $_POST['flavour_15']<>"" || $_POST['flavour_16']<>"" || $_POST['flavour_17']<>"" || $_POST['flavour_18']<>"" || $_POST['flavour_19']<>"" || $_POST['flavour_20']<>""){ $sql_end .= " AND feeds.product_feed_id = flavour.product_id "; } if ($_POST['ingredients_1']<>"" || $_POST['ingredients_2']<>"" || $_POST['ingredients_3']<>"" || $_POST['ingredients_4']<>"" || $_POST['ingredients_5']<>"" || $_POST['ingredients_6']<>"" || $_POST['ingredients_7']<>"" || $_POST['ingredients_8']<>"" || $_POST['ingredients_9']<>"" || $_POST['ingredients_10']<>"" || $_POST['ingredients_11']<>"" || $_POST['ingredients_12']<>"" || $_POST['ingredients_13']<>"" || $_POST['ingredients_14']<>"" || $_POST['ingredients_15']<>"" || $_POST['ingredients_16']<>"" || $_POST['ingredients_17']<>"" || $_POST['ingredients_18']<>"" || $_POST['ingredients_19']<>"" || $_POST['ingredients_20']<>""){ $sql_end .= " AND feeds.product_feed_id = ingredients.product_id "; } if ($_POST['dietary_1']<>"" || $_POST['dietary_2']<>"" || $_POST['dietary_3']<>"" || $_POST['dietary_4']<>"" || $_POST['dietary_5']<>"" || $_POST['dietary_6']<>"" || $_POST['dietary_7']<>"" || $_POST['dietary_8']<>"" || $_POST['dietary_9']<>"" || $_POST['dietary_10']<>"" || $_POST['dietary_11']<>"" || $_POST['dietary_12']<>"" || $_POST['dietary_13']<>"" || $_POST['dietary_14']<>"" || $_POST['dietary_15']<>"" || $_POST['dietary_16']<>"" || $_POST['dietary_17']<>"" || $_POST['dietary_18']<>"" || $_POST['dietary_19']<>"" || $_POST['dietary_20']<>""){ $sql_end .= " AND feeds.product_feed_id = dietary.product_id ";}$query=$sql_select . $sql_from . $sql_where . $sql_end . $sql_group . $sql_orderby; $product_results=dbselect( $query,"dbLinkInt" );