0

I am importing data from an xml, and it appears they use " latin1_swedish_ci" which is causing me lots of issues with php and mysql (PDO).

I'm getting a lot of these errors:

General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' 

I am wondering how I can convert them to proper UTF-8 to store in my database.

I've tried doing this:

        $game['human_name'] = iconv(mb_detect_encoding($game['human_name'], mb_detect_order(), true), "UTF-8", $game['human_name']);

Which I found here: PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

I still seem to get the same error though?

Community
  • 1
  • 1
NaughtySquid
  • 1,947
  • 3
  • 29
  • 44

1 Answers1

1

Don't use any conversion functions -- get utf8 specified throughout the processing.

Make sure the data is encoded utf8.

When using PDO:

$db = new PDO('dblib:host=host;dbname=db;charset=UTF-8', $user, $pwd);

Table definitions (or at least columns):

CHARACTER SET utf8

Web page output:

<meta ... charset=UTF-8>
Rick James
  • 135,179
  • 13
  • 127
  • 222