while (($test= fgetcsv($file, 10000, ",")) !== FALSE){
$field1= $test[0];
$field2= $test[1];
$sql= "INSERT IGNORE into tablename(field1, field2) values('$field1','$field2')";
mysql_query($sql);
}
I am importing data from a CSV file and then store this data into variables $field1 , $field2
then I try to insert into tablename table. IN CSV file i have many records. My query insert the data but its inserting duplicate records i use IGNORE in query but its not working for me.
How Can i prevent duplication?