title: How to import parse csv file to Maria DB?
body: <p>I have a php code where I am parsing the csv file and I want to import the parse data to maria db. How can I do that?</p>
  <p>My code:</p>
  <pre><code>&lt;?php 
  
  $row = 1;
  if (($handle = fopen(&quot;users.csv&quot;, &quot;r&quot;)) !== FALSE) {
      while (($data = fgetcsv($handle, 1000, &quot;,&quot;)) !== FALSE) {
          $num = count($data);
          echo &quot;&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n&quot;;
          $row++;
          for ($c=0; $c &lt; $num; $c++) {
              echo $data[$c] . &quot;&lt;br /&gt;\n&quot;;
          }
      }
      fclose($handle);
  }
  
  ?&gt;
  </code></pre>
  <p>Output:</p>
  <pre><code>Task1 % php user_upload.php
  &lt;p&gt; 3 fields in line 1: &lt;br /&gt;&lt;/p&gt;
  name&lt;br /&gt;
  surname&lt;br /&gt;
  email   &lt;br /&gt;
  &lt;p&gt; 3 fields in line 2: &lt;br /&gt;&lt;/p&gt;
  John&lt;br /&gt;
  smith&lt;br /&gt;
  jsmith@gmail.com&lt;br /&gt;
  &lt;p&gt; 3 fields in line 3: &lt;br /&gt;&lt;/p&gt;
  HaMish&lt;br /&gt;
  JONES&lt;br /&gt;
  ham@seek.com&lt;br /&gt;
  &lt;p&gt; 3 fields in line 4: &lt;br /&gt;&lt;/p&gt;
  Phil &lt;br /&gt;
  CARRY   &lt;br /&gt;
  phil@open.edu.au  &lt;br /&gt;
  &lt;p&gt; 3 fields in line 5: &lt;br /&gt;&lt;/p&gt;
  Johnny&lt;br /&gt;
  O'Hare&lt;br /&gt;
  john@yahoo.com.au&lt;br /&gt;
  &lt;p&gt; 3 fields in line 6: &lt;br /&gt;&lt;/p&gt;
  Mike&lt;br /&gt;
  O'Connor&lt;br /&gt;
  mo'connor@cat.net.nz&lt;br /&gt;
  &lt;p&gt; 3 fields in line 7: &lt;br /&gt;&lt;/p&gt;
  WILLIAM&lt;br /&gt;
  SMYthe&lt;br /&gt;
  happy@ent.com.au&lt;br /&gt;
  &lt;p&gt; 3 fields in line 8: &lt;br /&gt;&lt;/p&gt;
  HAMISH&lt;br /&gt;
  jones   &lt;br /&gt;
  ham@seek.com&lt;br /&gt;
  &lt;p&gt; 3 fields in line 9: &lt;br /&gt;&lt;/p&gt;
  Sam!!  &lt;br /&gt;
  WalTERS&lt;br /&gt;
  sam!@walters.org    &lt;br /&gt;
  &lt;p&gt; 3 fields in line 10: &lt;br /&gt;&lt;/p&gt;
  Daley&lt;br /&gt;
  thompson&lt;br /&gt;
  daley@yahoo.co.nz&lt;br /&gt;
  &lt;p&gt; 3 fields in line 11: &lt;br /&gt;&lt;/p&gt;
  kevin&lt;br /&gt;
  Ruley&lt;br /&gt;
  kevin.ruley@gmail.com&lt;br /&gt;
  &lt;p&gt; 3 fields in line 12: &lt;br /&gt;&lt;/p&gt;
  Edward &lt;br /&gt;
  JIKES&lt;br /&gt;
  edward@jikes@com.au&lt;br /&gt;
  &lt;p&gt; 1 fields in line 13: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 14: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 15: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 16: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 17: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 18: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 19: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 20: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 21: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  &lt;p&gt; 1 fields in line 22: &lt;br /&gt;&lt;/p&gt;
  &lt;br /&gt;
  </code></pre>
  <p>Also, for some reason it keep printing the extra lines even though I only have just 12 lines in my csv file. But how can I store the parse data to Maria DB? Also, I want it to capitalize the name and surname and lower case the email before inserting data to MYSQL. I am new to it so I am not sure, any help is appreciated.</p>