Below is my mysql table.
CREATE TABLE `mydb`.`mytable` ( `id` INT NOT NULL AUTO_INCREMENT, `comment` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM;
ALTER DATABASE mydb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE mytable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Below is my php code.
<?php
    if(isset($_POST["submit"])){
        $con = mysqli_connect("localhost","root","","mydb");
        $comment = mysqli_real_escape_string($con, $_POST['comment']);
        $sql="INSERT INTO `user`(`comment`) VALUES ('".$comment."')";
        if (mysqli_query($con, $sql)) {
            echo "New record created successfully";
          } else {
            echo "Error: " . $sql . "<br>" . mysqli_error($con);
          }
    }
?>
<html>
    <head></head>
    <body>
        <form method="POST">
            <input type="text" name="comment">
            <input type="submit" value="submit" name="submit">
        </form>
    </body>
</html>
when I try to submit with emojies in localhost, unknown characters were stored (inserted) in localhost. when I try to submit with emojies in 000webhost.com, no records were inserted to the database.
But I can store emojies directly in both database(localhost & 000webhost.com) by executing following sql command directly in mysql server(PHP MYADMIN).
INSERT INTO `mytable`(`comment`) VALUES ('');
But I couldn't insert emojies using PHP. So my question is how to insert emojies using PHP to mysql server?
 
    