How to insert EMOJI - SMARTFONES into Mysql database with PHP?

Asked

Viewed 1,942 times

12

Well, since the question is very self-explanatory I will only reinforce the question.

I have an APP chat system, which through the HTML, command to PHP with Ajax, but if the usurer tries to insert some emoji (Emotion) from your device in the database it receives: "?????" as a message.

How can I change this to receive some kind of code for each Emotion and on the site list according to its value?

inserir a descrição da imagem aqui

  • 1

    Very interesting question. The short answer would be: Convert the Character set from your table to utf8mb4, since this format accepts all Unicode characters.

  • I’ve tested it that way, but it didn’t work..

  • 2

    Even changing your column or table to utf8mb4 did not work? emojicolumn VARCHAR(255) CHARACTER SET utf8mb4? On the table: ALTER TABLE tabela CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;?

  • 2

    In addition to changing the charset, run this SQL before all calls involving Emoticon: SET NAMES utf8mb4;.

  • How is it being done is called ajax? This may be the problem too.

2 answers

2

Long live,

Briefly, you will need to convert the data added by users taking into account the type of device used. The most usual is to have to convert to Unified. I leave the link with the code ready to work. Say if you have problems.

See here http://code.iamcal.com/php/emoji/ .

-3

A simpler way is to add the emoji inside the message as a span with a specific CSS class that matches it. In the database, save the message normally as HTML.

Browser other questions tagged

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