Friday, July 13, 2018

PHP mysql charset utf8 problems











I'm developing some new features on a website that somebody else already developed.



I'm having a problem the charset.



I saw that the database had some tables in utf8 and some in latin1




So I'm trying to convert all the tables in UTF8.



I did it for one table (also the fields of this table now are utf8), but was not successful.



I'm using the normal mysql connect. I have to put any config to say that it must connect with utf8 to the DB? If yes witch one?



In my html I have:







It looks like some letters works and others display the question mark.
For example it not able to display this ’ that is different of this: '


Answer



Try this




header('Content-Type: text/html; charset=utf-8');

?>


and then in the connection



 $dbLink = mysql_connect($argHost, $argUsername, $argPassword);
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');

mysql_select_db($argDB, $dbLink);
mysql_query("set names 'utf8'",$dbLink);
?>

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...