check this out, i found it here on the forums
for ($i = 0; $i < $columns; $i++) {
$fields[] = mysql_field_name($result, $i);
}
if ($mysql[0] == 1 && array_key_exists($key, $fields)) ...
array_key_exists() checks to see if a KEY exists, not a value. You
are assigning the field names as values of the $fields array. Give it
a shot with in_array() instead of array_key_exists()...