K
K
Kirill Batalin2014-07-23 20:03:58
css
Kirill Batalin, 2014-07-23 20:03:58

How to add emoji to the database?

It is necessary to add text containing emoji emoticons to the database.
I tried this:

$str='<p>Текст с emoji. Еще текст</p>'; //Вместо emoji должен быть смайл
$res = $db->prepare("INSERT INTO `table` (`str`) VALUES (:str)");
$res->bindParam(":str", $str, PDO::PARAM_STR, 60);
$res->execute(); //В базе сохранится строка "<p>Текст с "

But the line is truncated. Only the text up to emoji is entered into the database. I tried to process the string with htmlentities();, but there is no result. Emoji remain untouched.
Encoding utf-8 if that matters.
Please tell me how to solve the problem

Answer the question

In order to leave comments, you need to log in

5 answer(s)
Y
Yuri Oliyarnyk, 2016-04-20
@FoxPro111

You can add this image with :before, give absolute positioning like the black checkbox, and give the image a z-index greater than the checkbox.
Then the picture will be on top of the black flag

K
Ksenia Mikhailova, 2016-04-20
@arizona

You cannot make an image that goes beyond the block using the background. Only to have a separate element, and to position.

Y
Yuri Chernyshev, 2014-07-23
@kir55rus

> Encoding utf-8 if that matters.
Has, use utf-8mb4

A
Alexander Didenko, 2016-10-25
@Bagunda

Yuri Chernyshev => Just fixing the table column encoding to utf-8mb4 had no effect

A
Alesha Hate, 2019-12-12
@aleshahate

I added emoticons to the database according to this principle.
There is a smiley with such unicode U+1F600
Then I specify in the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question