2013-05-09 70 views
-1

在PHP我有一個功能和功能內我有一個查詢這樣PHP函數示出錯誤()預計參數1是資源數組給定

public function hookHome($params) 
    { 
    $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); 
    global $cookie, $smarty; 
    $value=array(); 
    $sql_select="SELECT DISTINCT country_name,country_ISO from "._DB_PREFIX_."storeinfo where status='1'"; 
    $result=Db::getInstance()->ExecuteS($sql_select); 
     while($row=mysql_fetch_assoc($result)) 
     { 
     $value[] = $row; 
     } 
    $smarty->assign('array',$value); 
    $smarty->assign('default',$defaultLanguage); 
    } 

但它示出了查詢執行後mysql_fetch_array() expects parameter 1 to be resource, array given in storeinfo.php on line 8;

所以可以在這裏有一個人請你告訴我什麼是這裏的問題:像 警告錯誤?任何幫助和建議都將非常可觀。謝謝

+1

與10億28百萬和50個類似的情況一樣,您的查詢失敗,並且您沒有檢查返回值 – 2013-05-09 08:27:37

+0

錯誤消息甚至與提供的​​代碼不匹配。 – deceze 2013-05-09 08:28:52

回答

1

您的代碼$result=Db::getInstance()->ExecuteS($sql_select);正在返回一個數組。你需要一個mysql_resultset傳遞給mysql_fetch_assoc。

它似乎是你使用一些庫,是圍繞在MySQL擴展。你應該檢查一下它返回的結果,也許它自己有一個迭代結果的方法。

相關問題