title: How to input an array into INSERT INTO query?
body: <p>My array: </p>
  
  <pre><code>print_r($entryarray) = Array ( [Place] =&gt; lucky [Location] =&gt; India [Time] =&gt; [Info] =&gt; beautiful )
  </code></pre>
  
  <p>My code to insert the array into INSERT query:</p>
  
  <pre><code>if(count($entryarray) &gt;0 ) {
          $query = "INSERT INTO testing (";
          foreach($entryarray as $col =&gt; $val){
              $query.="$col,";
          }
          $query.=" )
          VALUES(";
          foreach($entryarray as $col =&gt; $val){
              $query.="$val,";
          }
          $query.=" )";
  }
  </code></pre>
  
  <p>But I am getting an error.</p>
  
  <blockquote>
    <p>Error: INSERT INTO testing (Place,Location,Time,Info, ) VALUES
    array_values(lucky,India,,beautiful, )</p>
  </blockquote>
  
  <p>How can I get <code>INSERT INTO testing ("Place", "Location", "Time", "Info").............</code>?</p>