Reputation: 97
Sorry in advance if this is a it of a dim question, I'm good at basic SQL stuff, but by no means a professional and character encoding goes WAY over my head.
I've currently got a basic commenting system set up on a site with a basic form that submits the contents of a textarea box to a MySQL database and I thought it would be a good idea to see if I can get emoji functioning in case anyone tries to enter one.
I've changed the encoding of the table to utf8mb4, and changed the changed the charset my page uses when connecting to the database to utf8mb4 too.
But that's about where my understanding of this ends and it still doesn't work. At present, when an emoji is entered into the database, I get a string of characters like this (for the Jack O' Lantern emoji):
🎃
I have no idea what kind of encoding that is, to be honest! Anyone know where I'm going wrong? As I said, all this stuff goes over my head so don't feel bad about dumbing it down for me 😝
Upvotes: 2
Views: 2771
Reputation: 68
You have to change your character set to utf8mb4.
EDIT: Found a very similar topic here: How to store Emoji Character in MySQL Database
EDIT 2: See my code on DB FIDDLE : https://www.db-fiddle.com/f/jpyVfGoE7xi1Deigspiii7/0
Upvotes: 1