Answer the question
In order to leave comments, you need to log in
How to change encoding when importing into mysql from csv file?
Good day to all.
add row to db
$handle = fopen($file, "r");
while (($line = fgetcsv($handle, 100, ";")) !== FALSE) {
$query = $db->prepare("INSERT INTO students (name,surname,age,city) VALUES (:name,:surname,:age,:city)");
$data = array('name' => $line[0], 'surname' => $line[1], 'age' => $line[2], 'city' => $line[3]);
$query->execute($data);
}
fclose($handle);
Answer the question
In order to leave comments, you need to log in
Before importing, specify in the code:
There are other ways to import:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question