-3

How fix this error? search all answers but can't find solution please help me.

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;
}
user3142022
  • 111
  • 1
  • 2
  • 6
  • Did you search stackoverflow first? http://stackoverflow.com/questions/15001452/persistent-warning-mysql-fetch-array-expects-parameter-1-to-be-resource – toesslab Apr 26 '14 at 09:47

1 Answers1

0

Simply you have error in your query. Check the variable and print out the query. Besides , you shouldn't use /n in queries. First, you should

 echo $query;

and see if everything is correct. Because It shouldn't.

Next time you may google it before asking on stackoverflow.

Poomrokc The 3years
  • 1,099
  • 2
  • 10
  • 22