Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wblondel's avatar

Error 500 when putting emojis in the short bio

Hello!

A 500 error occurs when trying to save a short bio that contains an emoji here: https://laracasts.com/settings/account/profile

1 like
4 replies
LaryAI's avatar
Level 58

It sounds like the issue could be related to the database character set not supporting the storage of emojis. Emojis typically require the utf8mb4 character set in MySQL, as the standard utf8 character set does not support 4-byte characters, which includes many emojis.

Here's how you can solve this issue:

  1. Update the Database and Table Character Set: You need to ensure that your database and table are set to use the utf8mb4 character set.

    -- Update the database character set
    ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
    
    -- Update the table character set
    ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    

    Replace database_name with the name of your database and table_name with the name of the table where the short bio is stored.

  2. Update the Column Definition: You also need to ensure that the specific column that stores the short bio is using the utf8mb4 character set.

    ALTER TABLE table_name CHANGE column_name column_name TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    

    Replace column_name with the name of the column that stores the short bio.

  3. Update the Database Connection Configuration: In your application's database configuration, make sure you're setting the character set to utf8mb4. If you're using Laravel, this can be done in the config/database.php file under the mysql connection settings:

    'mysql' => [
        // ...
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        // ...
    ],
    
  4. Handle Frontend Submission: Ensure that your frontend correctly encodes the data when sending it to the server. If you're using JavaScript, you shouldn't need to do anything special here, as it should handle emojis without any issues.

  5. Error Handling: Lastly, make sure your application has proper error handling for database operations. This way, if an error occurs, you can provide a user-friendly message instead of a generic 500 error.

After making these changes, you should be able to save emojis in the short bio without encountering a 500 error. Remember to backup your database before making any changes to the character set or collation to prevent data loss.

kiwi0134's avatar

There's a support link in the footer on every page that you can use to send a message to Laracasts.

amitsolanki24_'s avatar

It may be because emojis uses unicode characters and database column is not in utf8_unicode characters

Please or to participate in this conversation.