I want to insert data to phymyadmin table using CSV file from front-end of website, which must UPDATE all the record previously in my table.
This code isn't working at all. Please locate the error.
    <?php
   $servername = "localhost";
   $username = "";
             $password = "";
             $dbname = "";
             $conn = mysql_connect($servername, $username , $password );  
              if(! $conn ) {
      die('Could not Find Some Error Occured: ' . mysql_error());
                }
                if(isset($_POST["submit"]))
             {
              if($_FILES['file']['name'])
              {
               $filename = explode(".", $_FILES['file']['name']);
               if($filename[1] == 'csv')
               {
                $handle = fopen($_FILES['file']['tmp_name'], "r");
                while($data = fgetcsv($handle))
                {
                 $uname = mysqli_real_escape_string($connect, $data[0]);  
                 $pass = mysqli_real_escape_string($connect, $data[1]);
                 mysql_select_db('desiresq_record');
            $query = "INSERT into login (username, password)
                               VALUES        ('$uname','$pass')";
                   mysqli_query($connect, $query);
      }
      fclose($handle);
      echo "<script>alert('Import done');</script>";
     }
    }
   }
   ?> 
 
    