2013-07-23 83 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 –