I have a very strange problem with my PHP code.
All my charset are correct
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
I already use the code below to correct accent problems
header('Content-Type: text/html; charset=utf-8');
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
When I send the form to MySQL it writes to the bank with an accent correctly (database in latin1_swedish_ci).
Everything appears perfectly on the screen.
The problem appears when I make a str_replace. When I get the URL variable using the $ _GET method (which has the correct accent) and put it in the str_replace function, the function does not recognize the letter with an accent and does not make the change.
Now, if I write the same word in my code ( <?php $str = "joão" ?>
for example), then the function recognizes the accent.
The problem also happens when the code compares a word to what is in the database. If it compares a letter with an accent that is in the code with a word that has an accent in the database, it does not recognize (so it does not return any results).
I'm using str_replace to do searches with REGEXP, so my code takes a word with an accent, swap for an equal word without an accent (here I already have the error) and then create a string with REGEXP to search.
Please help me no longer know where to look!