Title: charset problem with wordpress
Last modified: November 4, 2024

---

# charset problem with wordpress

 *  [omipand](https://wordpress.org/support/users/omipand/)
 * (@omipand)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/charset-problem-with-wordpress/)
 * Hey,
   I am creating a PHP file that will make changes to the wordpress database
   tables. For reasons that are explained in detail, I do not want to use the internal
   functions of WordPress to insert data into the database.
 * In the PHP file, I save the data in the database, but in WordPress, it displays
   as a question mark.
 *     ```wp-block-code
       $mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);$mysqli->set_charset("utf8mb4");$sql = "INSERT INTO wp_st_room_availability     (post_id,check_in,check_out,number,post_type,adult_dbl_price,adult_price,child_price,child_nb_price,infant_price,extra_bed_price,status,priority,number_booked,parent_id,allow_full_day,number_end,booking_period,is_base,adult_number,child_number,room_price_modified,modified_by)VALUES ('$_room_id', '$_stamp', '$_stamp', '$_room_stock', 'hotel_room', '$_room_dbl_c', '$_room_sgl_c', '$_room_chdwb_c', '$_room_chdnb_c', '$_room_infant_c', '$_room_tpl_c', '$_status', NULL, 0, '$_hotel_id', 'on', NULL, 0, 0, 1, 0, NOW(), '$_modifier_name')";$result = $mysqli->query($sql);
       ```
   
 * The data stored in the database through WordPress is also read as unintelligible
   characters when read by this PHP file.
 * > > Ù†Ø§Ù… Ú©Ø§Ø±Ú¯Ø²Ø§Ø±
 * 
   Searching the internet, I found out that the problem is in the charset. In the
   wp-config.php file, the value
 *     ```wp-block-code
       define( 'DB_CHARSET', 'latin1' );
       ```
   
 *  is set.
   This WordPress site uses the Traveler theme, and I don’t know how to
   find out what charset it uses.
 * I tried utf-8, utf8mb4 and latin1 in my PHP file, but the problem was not solved.
 * I will be grateful if you help me to find the problem and solve it.
    -  This topic was modified 1 year, 7 months ago by [omipand](https://wordpress.org/support/users/omipand/).

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/charset-problem-with-wordpress/#post-18113935)
 * Your theme uses whatever charset your WP installation is configured for. The 
   default is UTF-8 and is hidden unless an alternative is chosen. You can see it
   at /wp-admin/options.php. Search the options list for “blog_charset”.
 * Mismatched charsets will be an ongoing problem. What charset does your DB actually
   use? You can find out via the phpMyAdmin app, usually accessed through your hosting
   account. The charsets for every DB is at information_schema.SCHEMATA. “utf8mb4”
   is a good choice. Latin1 not so much, but it’s workable as long as everything
   is Latin1. With Latin1 you will have difficulty with foreign characters that 
   are beyond ASCII code 255. Utf8mb4 will work for pretty much any character in
   existence.
 * The definition for ‘DB_CHARSET’ should match that of your DB. If there’s any 
   doubt, define it as an empty string to inherit the DB’s charset, whatever it 
   may be.
 * If all of your textual data is ASCII code 255 or less, you could switch from 
   Latin1 to utf8mb4 since the encoding is the same up to that point. There are 
   collations that relate back to a specific charset. The collations chosen should
   relate to your DB’s charset. There are collation settings for the entire DB, 
   for each table, and for each textual column. Unless there’s a specific reason
   not to, all of these should match.
 * Changing the collation in phpMyAdmin is trivial, but changing the charset itself
   requires certain SQL queries. Always make a full backup before doing so, as the
   conversion may have unanticipated undesirable consequences.
 * Your WP charset in options.php should match that of your DB, but the way it’s
   presented may vary because it’s used in a HTML tag. For example, “utf8mb4” in
   the DB should be presented in options and HTML as “UTF-8”.
 * Finally, it’s possible your theme’s chosen font simply has no glyphs (the graphic
   representation of a character) defined for certain characters. This can result
   in question marks for the missing glyphs. It’s possible there’s nothing wrong
   with your charsets and the issue is the chosen font. I don’t think this is the
   case here, but it’s worth mentioning.

Viewing 1 replies (of 1 total)

The topic ‘charset problem with wordpress’ is closed to new replies.

## Tags

 * [charset](https://wordpress.org/support/topic-tag/charset/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/charset-problem-with-wordpress/#post-18113935)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
