I have problem inserting rows to my DB.
When a row contains characters like: ‘è’, ‘ò’, ‘ò’, ‘€’, ‘²’, ‘³’ …. etc … it returns an error like this (charset set to utf8):
Incorrect string value: '\xE8 pass...' for column 'descrizione' at row 1 - INSERT INTO materiali.listino (codice,costruttore,descrizione,famiglia) VALUES ('E 251-230','Abb','Relè passo passo','Relè');
But, if I set the charset to latin1 or *utf8_general_ci* it works fine, and no errors are found.
Can somebody explain me why does this happens? I always thought that utf8 was “larger” than latin1
EDIT: I also tried to use mysql_real_escape_string, but the error was always the same!!!!
According to the doc for UTF-8, the default collation is
utf8_general_ci.If you want a specific order in your alphabet that is not the
general_cione, you should pick one of theutf8_*collation that are provided for theutf8charset, whichever match your requirements in term of ordering.Both your table and your connection to the DB should be encoded in
utf8, preferably the same collation, read more about setting connection collation.To be completely safe you should check your table collation and make sure it’s
utf8_*and that your connection is too, using the complete syntax of SET NAMESYou can find information about the different collation here