Anthony1234
Anthony1234

Reputation: 143

Display special characters returned from mySQL in drop down select box

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

Answers (3)

Arya
Arya

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

shaik.amesh
shaik.amesh

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

Akhilesh B Chandran
Akhilesh B Chandran

Reputation: 6608

Try using utf8_encode() function and see if it works.

Upvotes: 2

Related Questions