Perad Posted April 10, 2009 Share Posted April 10, 2009 Hello, Having a torrid time here. The site is Portuguese. The MySQL character set is ut8, the collation is ut8_general_ci In the database i have this word. 'MATENÇÃO'. It appears correctly in phpMyAdmin When it outputs to the webpage it becomes distorted. There are several things which I do not understand here. If I write this page into my default template file. (main_page.php) it works. It displays fine. If I write this word into my header file (header.php), it becomes distorted. If I echo this word instead of calling it from the database it displays correctly. The page in question can found here. 69.89.31.108/~nortavia/ntv/ Please check the various comments above the page, in the nav menu and below the menu. Do you have any idea what is going on? Link to comment https://forums.phpfreaks.com/topic/153457-character-sets-not-working-please-advise/ Share on other sites More sharing options...
thebadbad Posted April 10, 2009 Share Posted April 10, 2009 First of all, you're setting the wrong charset in your HTML meta tag: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> It should be: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> And a second thing; when connecting to your database, you'll have to set names and character set to UTF-8 in MySQL: <?php //connect to DB $connection = mysql_connect($db_host, $db_user, $db_pass) or die('Error connecting to database.'); //select DB mysql_select_db($db_name, $connection) or die('Error selecting database.'); //set names and character set to UTF-8 mysql_query("SET NAMES 'utf8'", $connection); mysql_query('SET CHARACTER SET utf8', $connection); ?> Link to comment https://forums.phpfreaks.com/topic/153457-character-sets-not-working-please-advise/#findComment-806256 Share on other sites More sharing options...
Axeia Posted April 10, 2009 Share Posted April 10, 2009 I summed up the steps I could remember I took myself to get it working in another thread about the same subject so you may want to take a look at it. Link to comment https://forums.phpfreaks.com/topic/153457-character-sets-not-working-please-advise/#findComment-806281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.