1

I already set my database and tables into utf8mb4_bin and utf8mb4_unicode_ci

header('Content-type text/html; charset=UTF-8');
include 'DATABASE.php';
$username = $_SESSION['username'];

setting the character sets client, results, and connection into utf8mb4

$query =$connect->query("SET character_set_client=utf8mb4");
$query =$connect->query("SET character_set_results=utf8mb4");
$query =$connect->query("SET character_set_connection=utf8mb4");

$query = "
      SELECT * FROM tbl_comment 
      WHERE parent_comment_id = '0' 
      ORDER BY comment_id DESC";

$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '';

Check sender name if he/she has commented

checkSenderNameinDB($username);

Displaying data

foreach($result as $row){
  if(strcmp($row["comment_sender_name"],$username)==0){ 
      $output .= '
          <div class="card light" style="border-left:none; border-right:none;"> <div class="card-content">
  <div class="card-header text-white bg-secondary" >By <b>'.$row["comment_sender_name"].'</b> <i id="facebook_time_ago" title="'.$row["datesent"].'">'.facebook_time_ago($row["datesent"]).'</i></div>
  <div class="card-body text-dark">'.$row["comment"].'</div>
  <div class="card-footer text-dark" align="right">
  <button type="button" class="btn btn-default reply text-dark" id="'.$row["comment_id"].'" title="Reply"><i class="fas fa-reply text-primary"></i></button>'.

  ' <button type="button" class="btn btn-default text-danger delete" name="delete" data-id="'.$row["comment_id"].'" title="Remove/Delete"><i class="fas fa-trash-alt"></i></button>

  <button type="button" class="btn btn-default text-dark edit" name="edit" data-id="'.$row["comment_id"].'" title="Edit"><i class="far fa-edit"></i></button></div>'.'</div>';} 
  • utf8mb4_unicode_ci sir – Gene Phillip Artista May 01 '20 at 06:06
  • you mean the comments itself? its VARCHAR – Gene Phillip Artista May 01 '20 at 06:09
  • Can i add you on FB in order for me to explain and show it to you in a clearer way aobut my problem :) – Gene Phillip Artista May 01 '20 at 06:14
  • theres no NVARCHAR in mysql sir – Gene Phillip Artista May 01 '20 at 06:35
  • @Gene Phillip Astista, can you check [How to show emojis in PHP](https://stackoverflow.com/questions/37410967/how-to-show-emojis-in-php) and [How to convert Emoji from Unicode in PHP?](https://stackoverflow.com/questions/33547233/how-to-convert-emoji-from-unicode-in-php) – Sanjay Surve May 01 '20 at 07:35
  • *"theres no NVARCHAR in mysql sir "* What does MySQL have to do with the question? You've tagged SQL Server. SQL Server has `nvarchar`, and if you're storing emoticons yiou **need** to use `nvarchar`. – Thom A May 01 '20 at 08:13
  • CODE FOR LOADING THE COMMMENTS `function load_comment(){ $.ajax({ url:'fetch_comment.php', method:'POST', success:function(data){ $('#display_comment').html(data); }});}` – Gene Phillip Artista May 02 '20 at 13:13
  • the above `code` is when i try to update/add/delete some comments, it will load all the comments for a real-time system, emojis are now showing but the second problem is when I load my comments the emojis turning into a unicode again :( then if i refresh only the webpage it turns back into emojis again – Gene Phillip Artista May 02 '20 at 13:17

0 Answers0