title: PHP - Import csv into database data too long
body: <p>I'm trying to upload a CSV file to save records into database with php. I used the sql method <code>LOAD DATA INFILE</code> but it didn't work anyway.</p>
  <p>Index.php has the form with <code>&lt;input name='csv' type='file' id='csv'/&gt;</code>.</p>
  <p>My file upload has 5 strings columns and 2 integers (last of them), moreover it has only two rows, header and values.</p>
  <p>They are the fields <code>NOT NULL</code> in 'usuarios' database.
  So here's the problem, when I trying to add a record (for instance: 'bea') it says that</p>
  <blockquote>
  <p>.....(sooo long)......K8docProps/app.xmlPK Data too long for column 'NombreUsuario' at row 1</p>
  </blockquote>
  <p>Yeah, readfile shows that, so I changed the details of every column (I don't think it was the problem) and put values <code>VARCHAR(200) / INTEGER(200)</code>, whatever it doesn't let me put more length because I tried <code>Specified key was too long; max key length is 767 bytes</code>.</p>
  <p>And here's my code, I made it with others examples:</p>
  <h3>subirCSV.php</h3>
  <pre>
      
      require ('../cabses.php');
      require ('../conecta.php');
      if (isset($_POST['submit'])) {
          if (is_uploaded_file($_FILES['csv']['tmp_name'])) {
              echo "File ". $_FILES['csv']['name'] ." uploaded successfully.";
              echo "Displaying contents:";
              readfile($_FILES['csv']['tmp_name']);
          }
          $handle = fopen($_FILES['csv']['tmp_name'], "r");
          $flag = true;
          while (($data = fgetcsv($handle, 1000, " ")) !== FALSE) {
              if($flag) { $flag = false; continue; }
              $import="INSERT INTO usuarios (NombreUsuario,PassUsuario,EmailUsuario,Nombre,Apellidos,IdPropietario,IdRol) VALUES 
                              (
                                  '".trim($data[0], '"')."',
                                  '".trim($data[1], '"')."', 
                                  '".trim($data[2], '"')."',
                                  '".trim($data[3], '"')."',
                                  '".trim($data[4], '"')."', 
                                  '".trim($data[5], '"')."',
                                  '".trim($data[6], '"')."'
                              )
                          ";
              $oConni->query($import) or die(mysqli_error($oConni)."____________".$import);
          }
          fclose($handle);
          print "Import done";
      } else {
          print "Not working";
      }
  
  </pre>
  <p>Maybe it was for the UTF-8 encode?</p>
  <p>This is my first question in StackOverFlow, so hello everybody from Spain! And thank you!</p>