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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:11:09+00:00 2026-05-27T21:11:09+00:00

i am trying to store Chinese character in mysql database,but it store some messy

  • 0

i am trying to store Chinese character in mysql database,but it store some messy character.
Please help..
here is my code-

<?php header("Content-Type: text/html; charset=UTF-8");
if(isset($_POST['submit']))
{
$conn=mysql_connect("localhost","root","") or die("CONNECTION FAILED"); 
 $db=mysql_select_db("mytest",$conn) or die("DATABASE DOES NOT EXISTS");
 mysql_query("SET character_set_client=utf8", $conn);
  mysql_query("SET character_set_connection=utf8", $conn);
mysql_query("INSERT INTO tbl_test(id,name)
VALUES (null, '".$_POST['fname']."')") or die(mysql_error());
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="" method="post">
Name: <input type="text" name="fname" />
<input type="submit" name="submit" />
</form> 
</body>
</html>
  • 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-27T21:11:11+00:00Added an answer on May 27, 2026 at 9:11 pm

    welcome to Charset Hell.

    In PHP, to use a certain character set, absolutely everything has to be in the same character set. If you’re intending to use UTF8, then everything needs to be UTF8. The database needs to be using UTF8 as its charset, the connection between the script and the DB needs to be UTF8 (it looks like you’ve taken care of this already), the PHP script itself needs to be saved as a UTF8 file (without a BOM, because having a BOM will just cause you more trouble later), and the browser has to be viewing the page generated by the script in UTF8 (you should use the header() command to send a content-type header that specifies this).

    If any link in the chain is not UTF8, you’ll end up getting junk displayed for certain character sequences that are valid in one character encoding, but not another. Whilst PHP has functionality for converting between charsets, it gets messy quickly and is best avoided.

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

Sidebar

Related Questions

I'm trying to store some data in DOM Elements ($.cache) on my plugin but
I trying to store some settings in NSUserDefaults, but It seems that the app
I am trying to store sub-query result in session variable using MySQL, but the
I'm trying to store data from a MySQL table into an PHP array variable.
I am trying to store coldfusion code in a database to be used for
Am trying to store files in NACL using PepperMount library. But I've some problem
I am trying to store Chinese characters (指事字 zhǐshìzì) through a web form. But
I am trying to store URL Image paths into MySQL DB. But i am
I'm trying to store MediumBlob data in MySQL using java. But I have no
I'm trying to store in a database some GPS data that I get from

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.