I am not able to insert data from CSV file with "¤" Character. Please help me to solve the problem.
Thanks a lot in advanced.
CSV File:
FirstName¤LastName¤City¤Year |$|
Bill¤Gates¤NW¤2013¤|$|
David¤Beckham¤London¤2010¤|$|
PHP Code:
$csv_file = "Contacts.csv";
$csvfile = fopen($csv_file, 'r');
$theData = fgets($csvfile);
$i = 1;
do
{
$insert_csv = array();
$insert_csv['FirstName'] = $data[0];
$insert_csv['LastName'] = $data[1];
$insert_csv['City'] = $data[2];
$insert_csv['Year'] = $data[3];
$query = "INSERT INTO LTE_noria_enodeb (FirstName, LastName, City, Year)
VALUES ('".$insert_csv['FirstName']."','".$insert_csv['LastName']."','".$insert_csv['City']."','".$insert_csv['Year']."')";
$req = new requete($site->db, $query);
echo $query;
}while ($data = fgetcsv($csvfile,1000,";","|$|"));
fclose($csvfile);
// I tried this way also.. But both are not working :(:(
$sql = 'LOAD DATA LOCAL INFILE "ContactsList" INTO TABLE Contacts(FirstName, LastName, City, Year) fields terminated by "¤" LINES TERMINATED BY "\n" IGNORE 1 LINES';
$req = new requete($site->db, $sql);