How To Show Emoji Stored In Database

How To Show Emoji Stored In Database - Emoji is Stored in Database Instead of showing ❤ Love 😋 Emoji's they are showing ????? Love ?????. So it's basically Database Charset and Collection Problem. So that's why we unable to get the Emojis on Front End. So we can use to Mysql Command for this.
ALTER TABLE TABLENAME CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE TABLENAME MODIFY COULMNNAME TEXT CHARSET utf8mb4; 
In First Command we can Change the Charset and Collate for table and after that Second Command is use to modify the Column Where Emojis are stored. In Laravel we can use these commands. Don't forget to use Laravel DB class for Database Queries.
DB::statement("ALTER TABLE TABLENAME CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
DB::statement("ALTER TABLE TABLENAME MODIFY COULMNNAME TEXT CHARSET utf8mb4;");
or in PHP We can use mysqli_set_charset($connect, 'utf8mb4')
$connect=mysqli_connect('localhost','databaseusername','databsepassword','databasename');
mysqli_set_charset($connect, 'utf8mb4');

$result=mysqli_query($connect,"select * from students");
while($row=mysqli_fetch_array($result))
{
   echo $row['columnname'];
}

Comments

Popular posts from this blog

Prestashop Create Admin Controller inside Admin Folder

Prestashop Pass Controller Variables To TPL

Prestashop Admin Controller get Access Denied Error