trim() function giving warning
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a><br>
  <a href="http://stackoverflow.com/questions/11674312/warning-mysql-fetch-expects-parameter-1-to-be-resource-boolean-given-error">Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given error</a>  </p>
</blockquote>



<p>I'm getting this warning</p>

<pre><code>Warning: trim() expects parameter 1 to be string, array given in ..
</code></pre>

<p>which is my trim line.
The full code is functioned to send an error when fields are empty. However, this error appears saying every field is empty, but only the 'native' field is meant to be required so thats my 2nd problem.
Thanks for any help!</p>

<pre><code>session_start();
$err = array();


$user_id = intval($_SESSION['user_id']);
// otherwise
if (isset($_POST['doLanguage'])) {
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");

// check if current user is banned
$the_query = sprintf("SELECT COUNT(*) FROM users WHERE `banned` = '0' AND `id` = 
'%d'",   $user_id);
$result = mysql_query($the_query, $link);
$user_check = mysql_num_rows($result);
// user is ok
if ($user_check &gt; 0) {

    // check for empty fields
    foreach ($_POST as $key =&gt; $val) {
        $value = trim($val);
        if (empty($value)) {
            $err[] = "ERROR - $key is required";
        }
    }
    // no errors
    if(empty($err)) {
        for($i = 0; $i &lt; count($_POST["other"]); $i++)


            $native = mysql_real_escape_string($_POST['native'][$i]);
            $other = mysql_real_escape_string($_POST['other'][$i]);
            $other_list = mysql_real_escape_string($_POST['other_list'][$i]);
            $other_read = mysql_real_escape_string($_POST['other_read'][$i]);
            $other_spokint = mysql_real_escape_string($_POST['other_spokint'][$i]);
            $other_spokprod = mysql_real_escape_string($_POST['other_spokprod'][$i]);
            $other_writ = mysql_real_escape_string($_POST['other_writ'][$i]);

        // insert into the database
        $the_query = sprintf("INSERT INTO `language`   
(`user_id`,`native`,`other`,`other_list`,`other_read`, `other_spokint`
,`other_spokprod`,`other_writ` ) VALUES ('%d','%s','%s','%s','%s','%s','%s','%s')",
  $user_id,$native,$other,$other_list,$other_read,
$other_spokint,$other_spokprod,$other_writ);

        // query is ok?
        if (mysql_query($the_query, $link) ){

            // redirect to user profile
            header('Location: myaccount.php?id=' . $user_id);
            }
        }
    }
}
</code></pre>
