views:

147

answers:

2

Hey!

I am populating this mysql table with data from a php (via post and using filter_input). The database is utf8 but when I have a user that inputs words with ^,',',~ like Não I get this -> Não

What do I have to do to make it show the correct values. Or should I try to make some correction when I retrieve the data??

UPDATE:

I have added a utf8_decode and now it is inserting ok. Anyone know how to convert the string that were already in the table?? I tried using the convert function but I can't make it work :(

UPDATE:

I am trying this code:

select convert(field using latin1) from table where id = 35;

And I am still getting this: Não I tried other encoding s but I never get the word Não

Anyone have any thoughts on this one??

+1  A: 

First, make sure your page is utf-8

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

next, if your on Apache, make sur your in UTF-8 in config file :

AddDefaultCharset UTF-8

or your can do it in a .php file like this :

header('Content-type: text/html; charset=UTF-8');

if you still have problem, you can use the encode function :

$value = utf8_encode($value);

Hope all this will help...

RVeur23
When I try echo utf8_encode("Não"); I get this-> Não :(
AntonioCS
I also tried changing the header but with no luck I am still getting does weird chars
AntonioCS
You should change the order: first HTTP header than META tag. Otherwise the HTTP header will override the META tag.
Gumbo
Just to know, if you simply do echo ("Não"); Do you have Não or something else on the screen ??
RVeur23
A: 

It looks like somewhere along the way something cannot handle Unicode. As a result, ã is getting interpreted as two separate characters. Make sure everything that handles strings is OK with Unicode.

Yuliy