HI, I have a problem with this query
SELECT * FROM table WHERE `name` LIKE '%tést%'
the HMTL and the SQL table both have utf-8 encoding but unfortunately there is no mysql_set_charset('utf-8')
and I'm NOT able to use it.
I've tried with iconv("UTF-8", "ISO-8859-1", $name)
but the query matches only test
.
I want to match all of these : test, tést, tèst, tëst
(as it would work with mysql_set_charset
)
edit:
SET NAMES utf8
is nigher possible ... the database is with utf8 encoding, unfortunately the content is being filled from web without mysql_set_charset
nor SET NAMES
.
Currently if these functions are used the results are messed up.
version()
5.1.41-3ubuntu12.9
edit2:
when I use SET NAMES utf8
it matches only tést
and they look like tést
when I use iconv("UTF-8", "ISO-8859-1", $name)
it matches only test
I have just performed a quick test, and MySQL works as you expect it to work.
Perhaps it's the way you connect to the database, you could try executing SET NAMES 'utf8'; before performing the queries and see if that helps!
Also, please note that mysql_set_charset should take utf8, with no dash! See an example from PHP to be sure!
Cheers!
Before the query try:
*edits*
Apprently depending on MySQL version you might also be required to use:
One final note, the database needs to be using the UTF-8 character set, to ensure this:
*More edits*
After reading your edits I think that this is a issue with your HTML/PHP encoding. On the page submitting the characters ensure that you set the headers properly:
You should also set this via meta tags:
Then set the multibyte encoding with the
mb_internal_encoding()
function:By default PHP uses ISO-8859-1.
try regexp with the desired regular expression like
SELECT * FROM table WHERE name REGEXP #REGULAR EXP HERE#
Have you tried SET NAMES?