title: Import CSV File in phpmyadmin using php
body: <p>Here is my code to import csv file using php. I can tun derstand the errors.Please get out of it....</p>
  
  <pre><code>             &lt;?php
  
             require_once 'database.php';
  
                  $database=new Database;
                $database-&gt;connect();
  
         if (!empty($_FILES)) {
  $file = $_FILES["file1"]["tmp_name"];
  $handle = fopen($file,"r");
  while ($data = fgetcsv($handle,10000, ","))
  {
      $query = "INSERT INTO personalinfo( id,name, age, gender, occupation, contact, email, uname, paswrd, created_date ) VALUES
          (
              '".addslashes($data[0])."',
              '".addslashes($data[1])."',
              '".addslashes($data[2])."',
              '".addslashes($data[3])."',
              '".addslashes($data[4])."',
              '".addslashes($data[5])."',
              '".addslashes($data[6])."',
              '".addslashes($data[7])."',
              '".addslashes($data[8])."',
              NOW()
          )
      ";
      $database-&gt;insert($query);
      echo "INSERT INTO personalinfo( id,name, age, gender, occupation, contact, email, uname, paswrd, created_date ) VALUES
          (
              '".addslashes($data[0])."',
              '".addslashes($data[1])."',
              '".addslashes($data[2])."',
              '".addslashes($data[3])."',
              '".addslashes($data[4])."',
              '".addslashes($data[5])."',
              '".addslashes($data[6])."',
              '".addslashes($data[7])."',
              '".addslashes($data[8])."',
              NOW()
          )";
      echo "&lt;br /&gt;";
      echo("Data inserted");
   fclose($file);
  }
  
   } 
  
   ?&gt;
  </code></pre>
  
  <p>Error comes like this:-</p>
  
  <p>Notice: Undefined index: file1 in /var/www/trainees/B9/Jinal/mvc/import.php on line 10</p>
  
  <p>Warning: fopen() [function.fopen]: Filename cannot be empty in /var/www/trainees/B9/Jinal/mvc/import.php on line 11</p>
  
  <p>Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /var/www/trainees/B9/Jinal/mvc/import.php on line 12</p>