0

I can't save some data in my mysql database.

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xC3' for column 'title' at row 1

row title use the collation utf8mb4_unicode_ci.

What's wrong with it? How could I save my data?

PS: I try pretty much every solution give in stackoverflow. That why I create a new thread.

Sancho
  • 1,288
  • 2
  • 25
  • 50
  • Some 8-bit data is leaking into your UTF-8 world. You need to find out where that came from. – tadman May 31 '21 at 08:09
  • Since that's an à it's probably something that is UTF-8, got mangled back into ISO Latin 1, and then smashed into your column again as UTF-8, but it's not UTF-8 now. – tadman May 31 '21 at 08:10

3 Answers3

0

C3 may indicate a utf8 character being interpreted as latin1. Or it may indicate "double encoding".

SHOW VARIABLES LIKE 'char%';

See... utf8

The solution is probably to connect with utf8mb4, not with the default.

What version of MySQL are you using? What parameters does Doctrine use when connecting?

Rick James
  • 135,179
  • 13
  • 127
  • 222
0

Am getting the same error while I try to upload (<- this type [UTF8]). '1366. Incorrect string value: '\xF0\x9F\x98\x80' for column'

But am changing the data type to 'mediumblob' then its working fine.

check out the screenshot. Now the error solved

enter image description here

Pradeep Kumar
  • 1,193
  • 1
  • 9
  • 21
0

I had the same error today and the reason for it was not MySQL, but PHP. I had a utf-8 string and cut it with substr() to 250 characters. The problem with substr() is, that it is not utf-8 safe, as it may cut special characters "in half".

Using mb_substr() solved my problem.