Reputation: 143
I am trying to display utf8 characters in a drop down box which is pulled from mySQL (utf8_general_ci) the characters are returning as diamonds with a ? in the middle on.
I have tried htmlspecialchars and htmlentities. And it returns a blank string. Site also has the charset set to utf-8.
Thank you very much.
Upvotes: 3
Views: 2113
Reputation: 734
To set the server's character set:
mysql> SET character_set_database = 'utf8mb4';
mysql> SET character_set_server = 'utf8mb4';
To view all MySQL variables relating to character sets:
mysql> SHOW VARIABLES LIKE '%character_set%';
To change character set in PHP application:
/* change character set to utf8mb4 */
if (!($mysqli->[set_charset][1]("utf8mb4")))
{
printf("Error loading character set utf8mb4: %s\n", $mysqli->error);
exit();
}
else
{
printf("Current character set: %s\n", $mysqli->character_set_name());
}
REFERENCE:
Upvotes: 0
Reputation: 1
$inn_qu=mysql_query("select * from catagory where ct_id='$id' order by c_id");
while($re=mysql_fetch_array($inn_qu)){
$trs=get_html_translation_table(HTML_ENTITIES);
$str=$re['c_rate'];
$encode=strtr($str,$trs)
Upvotes: 0