1

I am trying to insert an emoji () into mysql database.

When I insert it from php code it inserts as ????.

And when I try to copy and paste it into phpmyadmin the following error occurs:

Warning: #1366 Incorrect string value: '\xF0\x9F\x98\x8D' for column 'content' at row 1

The column 'content' is long text.

Then I tried it with utf8mb4_unicode_ci instead of utf8_unicode_ci collation but I still get the same result from php although it inserts correctly in phpmyadmin.

I have followed many tutorials online and made all the database changes suggested but I can't find an answer to my problem.

Can anyone help?

Thank you

Syscall
  • 19,327
  • 10
  • 37
  • 52
Dan
  • 103
  • 1
  • 13
  • Show us your code. – Mike Feb 15 '18 at 18:29
  • Thank you gattsbr, changing from SET NAMES 'utf8' to SET NAMES 'utf8mb4' when connecting to the database did the trick! – Dan Feb 15 '18 at 18:36
  • @DanielOrmerod - That is 1 of about 4 steps to make things right. You probably had the other steps already in place. – Rick James Feb 26 '18 at 04:07
  • @Rick James - I had already done the other steps you are referring to before asking my question on here. The SET NAMES was the only thing I had missed. – Dan Mar 03 '18 at 10:42
  • @DanielOrmerod - Good. My comment was more toward others reading this Q&A. `SET NAMES` may fail for them, only because they have not (yet) done the other steps. – Rick James Mar 03 '18 at 19:30

0 Answers0