Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:11:14+00:00 2026-05-28T08:11:14+00:00

This has been asked before, but the other poster’s concern had more to do

  • 0

This has been asked before, but the other poster’s concern had more to do with the original encoding of the document.

I have a MySQL database containing some Chinese text. The Collation I am using for those fields is utf8_unicode_ci. Using phpMyAdmin and browsing the database, the Chinese text appears as it should. When I try to display this text on a webpage however, I get ????? in it’s place. Here is my code:

<html>
    <?php
        header('Content-Type: text/html; charset=UTF-8');
    ?>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
        <?php
        // Code opening database and retrieving fields and such...

Is there something I am missing? I’ve also tried moving the PHP header() call to above the <html> tag but that doesn’t work either.

EDIT: Here is the database code:

$con = mysql_connect("localhost", "name", "pass") or die('Sorry, could not connect to database server');
mysql_select_db("database_name", $con) or die('Sorry, could not connect to database');
$query = "SELECT id,field1,field2 FROM table1 ORDER BY id ASC";
$result = mysql_query($query) or die('Sorry, could not get recipes at this time ');

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $id = $row['id'];
            $var1= $row['field1'];
            $var2= $row['field2'];
            echo"ID:$id The contents are $var1 and $var2.<br><br>\n";
 }

UPDATE: So I’ve addressed the issue with reading in the stored Chinese characters as UTF-8 using the line mysql_set_charset('utf8', $con);, but I am finding that when I want to add to this database, the Chinese text shows up as ????? again. For instance, if I am saving a string of Chinese characters as a variable

$chinese = "炒猪肉与蔬菜";
echo "$chinese<br>";

This shows ????? again. Any clues?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:11:15+00:00Added an answer on May 28, 2026 at 8:11 am

    This is a great resource: Handling Unicode Front to Back in a Web App

    The fix for the initial question was to add the line mysql_set_charset('utf8', $con); after the line mysql_select_db();.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked before but the other solutions didn't work
I'm sure some variation of this question has been asked before but all other,
I know this question has been asked countless times before, but the other threads
I apologise if this has been asked before but I can't find the info
This has been driving me nuts. I hope it's not been asked before but
Ok, I know this has been asked before but after searching I couldn't find
This question has been asked before ( link ) but I have slightly different
This has been asked before (question no. 308581) , but that particular question and
I'm sure this has been asked before, but I can't find it. What are
I know this has been asked before, but I've found a different way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.