title: Adding Session / Array to SQL Database
body: <p>I have the session created and it stores the data, that is working 100%;</p>
  
  <p>I have a foreach loop that converts all the session data into an array of in_fields and in_values.</p>
  
  <p>But the form is not submitting to the database, please assist !</p>
  
  <pre><code>    // sql fields and values
  $in_fields = array();
  $in_values = array();
  
  
  foreach($_SESSION as $key =&gt; $value) {
      if(!empty($value)) {
          $value = sql_escape($value);
          $key = explode("#",$key);
  
              $in_fields[] = "`{$key[0]}`";
              $in_values[] = "'{$value}'";
      }
  }
  
  if(!empty($in_fields)) {
  
      $sql  = "INSERT INTO wills(";
      $sql .= implode(", ",$in_fields);
      $sql .= ") VALUES (";
      $sql .= implode(", ",$in_values);
      $sql .= ")";
  
  if(executeSql($sql)) {
          $id = mysql_insert_id();
                  executeSql($sql);
              }
          }
  </code></pre>
  
  <p>I have created a print_r of $in_fields and $in_values and it displays as an array.</p>
  
  <p>The error i am receiving now:</p>
  
  <pre><code>Warning: trim() expects parameter 1 to be string, array given in E:\xampp\htdocs\sc\form\inc\functions.php on line 22
  </code></pre>
  
  <p>Database query error.
  Unknown column 'step' in 'field list'</p>
  
  <p>LIne 22 from Functions.php</p>
  
  <pre><code>    $value = get_magic_quotes_gpc() ? stripslashes($value) : trim($value);  
  </code></pre>