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 7530785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:00:24+00:00 2026-05-30T05:00:24+00:00

I am importing data from outside into my database MYSQL using PHP Scripts. Encoding

  • 0

I am importing data from outside into my database MYSQL using PHP Scripts. Encoding my database charset to utf8 from the query

ALTER DATABASE DEFAULT CHARSET 'utf8';

then i executed a query to see all charsets by

SHOW VARIABLES LIKE 'character_set%';

output is:

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

as we can see character_set_database is set to utf8 but still if i write a code from my PHP Script to see the encoding as

echo $charset = mysql_client_encoding($cn);

the output is latin1 . From the above query latin1 is for server only. Can anyone tell me what exactly i am missing as i am unable to encode my Chinese and Japaneses characters to database.

EDIT

I am importing a database from outside which have unicode characters as 我的上网主页 and 嶏紞鎴戠殑 in Chinese , Japaneses and other different languages.
But when i import data to my database tables i get ????? instead of above characters. How can i encode these characters? Is it utf-8 or 16 and how i can recognize that which encoding will support these characters?

  • 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-30T05:00:25+00:00Added an answer on May 30, 2026 at 5:00 am

    character_set_database just refers to the default character set of any created tables in that DB, I think. Therefore, having it set to UTF8 won’t help, I suggest the following:

    Every time I initialize my database connection, I execute $db->query("SET NAMES 'utf8'");

    Talks about SET NAMES
    https://stackoverflow.com/a/1650834/1221902

    More on set names for the critics

    It will depend on your MySQL/PHP version for the availability of the appropriate function that would be a better alternative to the "SET NAMES 'utf8'" query.

    A SET NAMES ‘x’ statement is equivalent to these three statements:

    SET character_set_client = x;
    SET character_set_results = x; SET character_set_connection = x;

    From http://dev.mysql.com/doc/refman/5.1/en/charset-connection.html
    MySQL 5.1 (alot of people still use 5.1)

    The character_set_results system variable indicates the character set
    in which the server returns query results to the client. This includes
    result data such as column values, and result metadata such as column
    names.

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

Sidebar

Related Questions

I'm importing data from youtube into a textarea using Javascript. If you I simply
I'm importing data from a legacy application (php + mysql) to a rewritten version
So, I'm importing data from one database into another. There are about 5,000 records
I'm importing data in a SQL Server 2008 database from excel file where the
I'm importing data from an Excel sheet on to a DataTable using the following
I am importing data from a flat file into a normalized table structure. I
I'm importing data from SQL Server to mysql. Currently I need to migrate a
I had used JExcel API for importing Data's from Excel,for using JExcel , I
I am importing a database from outside which have unicode characters as 我的上网主页 and
I'm importing data from 1 database to another. I've been requested to strip all

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.