Reputation: 644
Unable to fetch characters as in MySql database below is the table.
Table1
+-------------------------------+
| APH | ID0 |
+-------------------------------+
| A | Costa Rican Colón |
| B | Icelandic Króna |
| C | Somali Shilling |
| D | Nicaraguan Córdoba |
+-------------------------------+
when i get the from db by using PDO in php then the above character shown like this
Costa Rican Col�n
what should i do?
Upvotes: 1
Views: 55
Reputation: 191
After fetching from mysql you need to use htmlentities like below in PHP
$str = htmlentities('Costa Rican Colón');
echo $str;exit;
Upvotes: 2
Reputation: 531
When you are fetch data then using this function for character function.
function charConversion($string, $to = "HTML-ENTITIES", $from = 'UTF-8,ASCII,ISO-8859-9,ISO-8859-1') {
$str = mb_convert_encoding($string, $to, $from);
$str = stripslashes($str);
if (empty($str)) {
return $string;
}
return $str;
}
Upvotes: 0