I've just a simple query to fetch a students records by his name, written in Bengali.

$student_rcrd = $wpdb->get_results("SELECT * FROM student WHERE name='আবুল কালাম আজাদ'");

Although my database have a record for 'আবুল কালাম আজাদ', the query returns zero row! But instead of this query, it works absolutely fine-

$student_rcrd = $wpdb->get_results("SELECT * FROM student WHERE name='Abul Kalam Azad'");
  • The name field in the database is 'utf8_unicode_ci'
  • Did you check the SQL directly, like from PHPMyAdmin?
    – Fayaz
    Sep 6, 2018 at 5:19
  • Also, if you are using the unicode text directly in the file (not from user input), then make sure the php file itself is saved as unicode UTF8 (without BOM) from your editor.
    – Fayaz
    Sep 6, 2018 at 5:21
  • I have checked the SQL from phpMyAdmin and it returns the row. the unicode text is actually inserted by the user. For Simplification I mentioned the query directly. Sep 6, 2018 at 5:32
  • 1
    Check what charset is defined in wp config file. try setting this define('DB_CHARSET', 'utf8mb4'); or define('DB_CHARSET', 'utf8');
    – CodeThing
    Sep 6, 2018 at 5:34
  • 1
    I'm not sure, but it may be a collation issue. Try using: add_filter( 'pre_get_table_charset', '__return_false' ); before the query and see if it works. If it does, then it's a collation issue (don't actually use it on production, this is just for test).
    – Fayaz
    Sep 6, 2018 at 5:47

1 Answer 1


Your data are possibly corrupt from trying to store multibyte characters that your DB could not correctly represent. MySQL's utf8 collation isn't actually UTF-8. You will have to convert your tables' character sets to utf8mb4 (real UTF-8), and then set the DB_CHARSET constant to match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.