Problem with different encodings between databases

Asked

Viewed 73 times

2

I am creating an application that needs to take some data that is in an SQL Server database with iso-8859-1 encoding, and insert into a Mysql database with utf-8 encoding.

A few words with accents are giving error when inserting into Mysql database.

Incorrect string value: '\xC7AFR\xC3O' for column 'produto' at row 1

The word that appears with error is Saffron. How can I get around this error and enter the record in the database?

Obs: I’m using PHP

  • Good morning! Tried to use replace in SQL?

  • No. How can I use?

  • field = REPLACE(field, 'TAG1', ') - field = field name, tag1 = tag that will be replaced and ' ', will be replaced by empty... I believe that the problem there would be the '', then you would exchange the tag1 for and leave the next empty.. You can test a manual insertion to see...

  • 2

    Already tried http://php.net/manual/en/function.utf8-encode.php and http://php.net/manualen/function.utf8-decode.php?

  • I tried @Gerep, it didn’t work.

  • @Andrébaill, I’ll try, thank you

  • 3

    Post the minimum code please.

Show 2 more comments

1 answer

1


Try using this function to convert the string to UTF-8:

mb_convert_encoding($string, "UTF-8", mb_detect_encoding($string, "UTF-8, ISO-8859-1, ISO-8859-15", true));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.