mysql - How to store Emoji Character in My SQL Database -
i using emoji character in project. characters saved (??) mysql database. had used database default collation in utf8mb4_general_ci
. show
1366 incorrect string value: '\xf0\x9f\x98\x83\xf0\x9f...' column 'comment' @ row 1
1) database: change database default collation utf8mb4
.
2) table: change table collation character set utf8mb4 collate utf8mb4_bin
.
query:
alter table tablename convert character set utf8mb4 collate utf8mb4_bin
3) code:
insert tablename (column1, column2, column3, column4, column5, column6, column7) values ('273', '3', 'hdhdhdh😜😀😊😃hzhzhzzhjzj æˆ‘çˆ±ä½ ❌', 49, 1, '2016-09-13 08:02:29', '2016-09-13 08:02:29')
4) set utf8mb4
in database connection:
$database_connection = new mysqli($server, $user, $password, $database_name); $database_connection->set_charset('utf8mb4');
Comments
Post a Comment