title: LOAD DATA INFILE To Import CSV File Into Database Table
body: <p>As a workaround, I am trying to use this syntax to import my csv file into my database table instead of <code>fgetcsv</code> because files uploaded may be quite big. So I made this:</p>
  
  <pre><code>$connect = mysql_connect("localhost","root",""); 
  mysql_select_db("dbtest",$connect);
  
  $filename = $file_path;
  
  $sql = "LOAD DATA INFILE '$filename'
          INTO TABLE tbltest
          FIELDS TERMINATED BY '|' 
          LINES TERMINATED BY '\n'
          (@rcode, @pcode, @mcode, @bcode, @ecode, @filetype, @rec_count, @ges_count, @ck_count, @ic_count, @ran_count);" ;
  
          //echo $sql;
          mysql_query ($sql,$connect) ;
  </code></pre>
  
  <p>Now, the problem is nothing is inserted in my table. When I do <code>echo $sql</code>, the result is this:</p>
  
  <pre><code>LOAD DATA INFILE 'uploads/testfile.csv' INTO TABLE tbltest FIELDS TERMINATED BY '|'
  LINES TERMINATED BY '\n' (@rcode, @pcode, @mcode, @bcode, @ecode, @filetype, @rec_count, 
  @ges_count, @ck_count, @ic_count, @ran_count);
  </code></pre>
  
  <p>The testfile.csv looks like this:</p>
  
  <pre><code>01|01|01|01|0000|FORM1|5|5|5|||||||||
  01|01|01|01|0000|FORM2|238|238||||||||||
  01|01|01|01|0000|FORM4|0|||||||||||
  01|01|01|01|0000|FORM5|1|||||||||||
  01|01|01|01|0000|FORM3|3|3||||||||||
  </code></pre>