title: Array to string conversion in Error
body: <pre><code>$keyNames = array();
  $keyVals = array();
  
  foreach ($varArray as $key =&gt; $name) { 
  
      $keyNames .= $key . ', ';
  }
  
  foreach ($varArray as $key =&gt; $val) { 
  
      $keyVals .= '\'' . $val. '\', ';
  }
  
  // build query
  $sql = "INSERT INTO Organizations (";
  $sql .= rtrim($keyNames, ", ");
  $sql .= ") VALUES (";
  $sql .= rtrim($keyVals, ", ");
  $sql .= ");";
  echo "&lt;div style=\"padding:5px;background-color:#efefef\"&gt;".$sql."&lt;/div&gt;"; // this output is working
  </code></pre>
  
  <p>I am trying to get the above code to work without error. IT currently works but I am getting  " Array to string conversion in" error even though I am getting the result that I am expecting.</p>
  
  <p>I am trying to build an sql query from array elements. Both loops throw an error but the echo SQL is giving me what I want. I just want to get rid of the error. I have tried (string) and (array) and implode() and join() but I have not been able to clear the error.</p>
  
  <p>Can you point me in the right direction?</p>