• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

In a PHP script, I execute a mysql SELECT query to find a word with the letter "é" in it, but it doesnt return the row. (it exists)

I am using  
$result = mysqlQuery('SELECT name FROM `titles` WHERE name = "général" ');
in a PHP script.

mysqlQuery() is my own wrapper for executing queries, it works.

There's a record général in the table, when I use phpMyAdmin and execute the same query, it can find the row. But in the php script it doesnt return anything.  I assume it has something to do with the encoding?

MySQL is utf8_unicode_ci
0
Octalys
Asked:
Octalys
  • 2
1 Solution
 
boon86Commented:
try this:

$conn = mysql_connect('host', 'user', 'password');
mysql_set_charset('utf8',$conn);
0
 
hernst42Commented:
Are you sure the file you use is encoded in utf8 and not in iso?
0
 
OctalysAuthor Commented:
Hi, I already tried mysql_set_charset already didnt change anything.



            $text = mb_convert_encoding($text, 'UTF-8', 'UTF-8');

didnt change anything either.
0
 
OctalysAuthor Commented:
Ok found the answer, it was mysql_set_charset that was giving me some weird problems. Rewrote it and suddenly it works.

I did a mysql query SET NAMES 'utf8' first and it worked, so I knew it was mysql_set_charset that wasnt working properly.

thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now