title: php: importing multiple csv files into mysql table
body: <pre><code>&lt;?php
  
  error_reporting(E_ALL);
  ini_set('memory_limit', '512M');
  ini_set('display_errors', 'ON');
  
  $host = "127.0.0.1"; // Host name
  $username = "root"; // Mysql username
  $password = ""; // Mysql password
  $db_name = "test2"; // Database name
  $tbl_name = "tcg_unique";
  
  $con = mysql_connect("$host", "$username", "$password")or die("cannot connect");
  $db_con = mysql_select_db($db_name) or die("cannot select DB");
  $charset = mysql_set_charset('utf8',$con);
  
  $dir_iterator = new RecursiveDirectoryIterator("/Users/jacksons/Dropbox/MTG/SQL staging");
  $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
  
  foreach ($iterator as $file) {
  echo $file, "\n";
  if(strpos($file, '.csv') !== false){
  mysql_query("LOAD DATA LOCAL INFILE '$file' INTO TABLE $tbl_name") or die (mysql_error());
  }
  else{
      print "else";
  }
  }
  </code></pre>
  
  <p>I am tying to load multiple csv files from a directory.  I am getting all the file path's to print out, but i am not able to get the data to load into the tables.  I tried one in mysql and it imported with no problem (all the column names matched).  Any help would be greatly appreciated.</p>
  
  <p>csv looks like:
  cardname    vendor  condition   price   shipping    quantity    Date
  Brimaz, King of Oreskos Game Citadel    Near Mint   18  0.5 4   5/30/14
  Kiora, the Crashing Wave    FTW Games   Lightly Played  13.09   NA  1   5/30/14
  Courser of Kruphix  Chicagoland Games   Near Mint   11.68   0.75    3   5/30/14</p>