Reputation: 39
i have a php script that has to compare some words in a csv file to a mysql table element. The problem is that apparently the csv file is'nt created in the correct codification.
The first error is this: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like'
Now when i use utf_encode
on the variable, the error goes away but it didnt find my variable int the mysql database.
To be clear, i have several accented words in my csv file, and i can´t change thhis.
i'm using latin1 charset and latin1_general_ci collation in my DB.
Another observation is that i'm using thw following code to get information in the file:
if (($handle = @fopen("../arquivos/atualização/$name", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
Can i somehow convert my csv file in php without losing the accents? or convert my db tables?
Note: in notepad++ my CSV file is in ANSI codification, and when i convert it to utf the accents turn into strange characters.
Upvotes: 1
Views: 13