2013-07-23 76 views
-1

我有下面這段PHPPHP畸形查詢SQL 1064錯誤

$manufacturers_query_raw = "select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from " . TABLE_MANUFACTURERS . " order by manufacturers_name"; 
$manufacturers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS_ADMIN, $manufacturers_query_raw, $manufacturers_query_numrows); 
$manufacturers_query = tep_db_query($manufacturers_query_raw); 
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) 
{ 
if ((!isset($HTTP_GET_VARS['mID']) || (isset($HTTP_GET_VARS['mID']) && ($HTTP_GET_VARS['mID'] == $manufacturers['manufacturers_id']))) && !isset($mInfo) && (substr($action, 0, 3) != 'new')) { 
    $manufacturer_products_query = tep_db_query("select count(*) as products_count from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers['manufacturers_id'] . "'"); 
    $manufacturer_products = tep_db_fetch_array($manufacturer_products_query); 
    $mInfo_array = array_merge($manufacturers, $manufacturer_products); 
    $mInfo = new objectInfo($mInfo_array); 
} 

我也得到網頁上的以下錯誤:

1064 - 你在你的SQL語法錯誤;請檢查與您的MySQL服務器版本相對應的手冊,以便在第1行'select manufacturers_id,manufacturers_name,manufacturers_image,date_added,la'處使用正確的語法。

select count(select manufacturer_id,manufacturer_image,date_added,last_modified from通過manufacturers_name廠家順序)的總

請幫助。非常感謝。

+2

題外話:不要使用'$ HTTP_GET_VARS'。它已經過時(並且已經過時了很長時間)。改爲使用'$ _GET'。 – Spudley

回答

0

我不明白SELECT COUNT內需要額外的select語句()?

select count(*) as total 

會做同樣的事情:

select count(select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from manufacturers order by manufacturers_name) as total 

(如果它是有效的)

+0

在哪裏寫PHP –

+0

內的修改,我認爲你向我們展示了錯誤的代碼 - 它抱怨查詢關於似乎並不在你發佈什麼來描述。難道還有其他的查詢在構造函數中的'splitPageResults()'怎麼回事? – Alfie

+0

不看起來。該功能僅作用於的$ manufacturers_query_raw值,$ manufacturers_query_numrows –