title: Cannot seem to get CSV data inserting into the database
body: <p>I currently have a CSV which once uploaded should be read by the upload.php and then upload this data to the database.</p>
  
  <p>At the moment I can see that it is getting the array, correct data from the CSV file and it also is trying to insert the correct data to the database but it just doesn't seem to be eventually inserting the data into the database.</p>
  
  <p>What could this be?</p>
  
  <p>Code Below:</p>
  
  <p>upload.php</p>
  
  <pre><code>&lt;?php
  include('config.php');
  
  $file = "test.csv";
  $separator = ",";
  $length = 0; // size of the longest line(!), 0 = no limit
  $fields = array('title', 'firstName', 'secondName', 'emailAddress', 'houseNumber', 'mobileNumber', 'address1', 'address2', 'address3', 'address4', 'postcode'); // use it as a white list
  
  $handle = fopen($file, "r");
  
  // get 1st line (header) and flip keys and values
  // format like [title] --&gt; 0, [firstName] --&gt; 1, ...
  $header = array_flip(fgetcsv($handle, $length, $separator));
  
  $values = array();
  
  // while we can read lines as csvData:
  while(($csvData = fgetcsv($handle, $length, $separator)) !== false){
      foreach ($fields as $field){ // put all values in an array in correct order
          $values[] = $csvData[$header[$field]];
          echo $field."&lt;br&gt;";
          mysql_query("INSERT INTO csv (" . implode(',', array_keys($header)) . ") VALUES (" . implode(',', $values) . ")"); 
      }
  }
  fclose($handle);
  
  ?&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>