Encoding Characters from a MySql Database

hi,
i am currently working on an ajax/jquery application with php and mysql, where i need to retrieve strings from the database which contain characters like: áéíóú. The values can be retrieved from the database without a problem, and displayed in my <div> tag.

Unfortunately, the results page shows the characters looking like this:���.

I tried setting the character set on the page to utf8 but this didn’t work, and I also tried a “utf8 encode” on this set of results but it seemed to conflict with the “implode” function.


echo (count($results) > 0)?“Search Results: {$searchTerms} :” . implode(“”, $results):“”;

Is there a way to get around this? Is the encode function the only/best way to do this? Maybe it can be done with javascript code?..

Thanks in advance

In what way does it conflict with implode?

if(empty($results)){
    printf('Search results for "&#37;s": %s', $searchTerms, utf_encode(implode('', $results)));
}

brilliant! thanks a million, i was trying to do a separate function, but this line of code works like a charm… thanks again