2014-04-26 139 views
-3

中給出如何解決此錯誤?搜索所有答案,但無法找到解決方案,請幫助我。PHP警告:mysql_fetch_array()期望參數1是資源,布爾在

line error:while($ record = mysql_fetch_array($ result)) line error:list($ id,$ aRecord [$ id])= $ record;

function getSelectData($DBName, $DBField, $allData = true, $DBOrderField = "0", $check_auth = false) 
{ 
    if($DBOrderField == "0") 
    { 
     $DBOrderField = $DBField; 
    } 

    if($allData == true) 
    { 
     $whereCondition = " WHERE %auth_filter%"; 
    } 
    else 
    { 
     $whereCondition = " WHERE " . $DBName . "_id <> 0 AND %auth_filter%"; 
    } 

    $query = "\n   SELECT " . $DBName . "_id, " . $DBField . " AS name\n   FROM " . $DBName . " " . $whereCondition . "\n   ORDER BY " . $DBName . "." . $DBOrderField; 
    return getSelectData_custom($DBName, $query, $check_auth); 
} 

function getSelectData_custom($DBTable, $query, $check_auth = false) 
{ 
    $result = db_query($DBTable, $query, array(), $check_auth); 
    $aRecord = array(); 
    while($record = mysql_fetch_array($result)) 
    { 
     if(!empty($record[1]) && !is_null($record[1])) 
     { 
      list($id, $aRecord[$id]) = $record; 
     } 

    } 
    return $aRecord; 
} 
+0

你是先搜索stackoverflow嗎? http://stackoverflow.com/questions/15001452/persistent-warning-mysql-fetch-array-expects-parameter-1-to-be-resource –

回答

0

只是你有錯誤的查詢。檢查變量並打印出查詢。另外,你不應該在查詢中使用/ n。首先,你應該

echo $query; 

看看是否一切正確。因爲它不應該。

下一次你可以谷歌它之前問在stackoverflow。

相關問題