Query using unicode

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I have set up a MySQL database (MySQL 4.1) which is encoded in UTF-8
with the utf8_general_ci collation. Inserted into the database is some
Japanese dictionary information.

Now I'd like to querie my database from within a PHP5 script. I have a
webform where the user inputs the Japanese data that needs to be queried
(webpage uses UTF-8 encoding). In my script I tell the database that I'm
sending unicode data: $db->query("SET NAMES 'utf8'");

Then I construct a query that looks like:


The variable term contains the user inputted utf-8 data. However, this
query does not work. It gives zero results (and I've made sure that the
requested data is actually in the database).

The data in $term seems correct (it displays correctly when I echo the

What am I missing here?

Re: Query using unicode

i still new also in the field but just want to throw an idea.. is we
need to do some header control ...
to indicate that our form is japanese charachter form set ??

any one can help??

Re: Query using unicode

badz wrote:
Quoted text here. Click to load it

Actually the form is working ok (I have the following header in my html:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

You can check it at www.belgium-anime.com/vocablist/search.php5

Try for example to look for the word はなび (hanabi) (this message is
encoded in ISO-2022-JP). This word is in my vocabulary list. I can
retrieve the input from the form correctly (As you can see when
submitting the form. The inputted data gets displayed correctly, the
query is also displayed correctly).

For some reason the query gives no result. I'm sure the data in my
database is correct, because I use it for another webpage

Do I perhaps need a special comparison operator to compare non-standard

Any help is appreciated!

Re: Query using unicode

Kris wrote:
Quoted text here. Click to load it


I can't help you myself with this problem, but I would advise you to ask
the question on the MySQL general mailing list. The MySQL developers
hang out on that list.

See <http://lists.mysql.com/mysql>">http://lists.mysql.com/mysql>


Real e-mail address unavailable. 5000+ spams per month.

Re: Query using unicode

Kris wrote:
Quoted text here. Click to load it

Don't forget to put quotes on the string!

Hint: try searching for "KANA LIMIT 5"

-- brion vibber (brion @ pobox.com)

Site Timeline