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)

Posted on 2011-10-07
Last Modified: 2012-05-12
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
Question by:Octalys
    LVL 7

    Accepted Solution

    try this:

    $conn = mysql_connect('host', 'user', 'password');
    LVL 48

    Expert Comment

    Are you sure the file you use is encoded in utf8 and not in iso?

    Author Comment

    Hi, I already tried mysql_set_charset already didnt change anything.

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

    didnt change anything either.

    Author Closing Comment

    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.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to count occurrences of each item in an array.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now