[Webinar] Streamline your web hosting managementRegister Today


How to read chinese characters from mysql by php4

Posted on 2008-01-27
Medium Priority
Last Modified: 2013-12-12
Dear all,
I would like to know how to read chinese characters from mysql by php4.
the php4 script as following, what is the problem by php4 so that I can't read chinese character.

please help
Thank you

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      $db_username = 'vh1199_kennam';
      $db_password = 'kennam007';
      $db_name     = 'vh1199_kennam';

$link = mysql_connect('localhost', $db_username, $db_password);
if (!$link){
//  die('Could not connect: ' . mysql_error());
} else {
//  echo 'Connected successfully';

$db_selected = mysql_select_db($db_name, $link);
if (!$db_selected) {
//  die ('Can\'t use foo : ' . mysql_error());
} else {
//  echo 'database successfully';


$query = "select * from produces where pro_type='plasticbag' and enabled='1'";
$resultset =  mysql_query( $query, $link );
if (!$resultset) {
//  die('Invalid query: ' . mysql_error());
} else {
//  echo 'resultset successfully';

while ($row = mysql_fetch_array($resultset)) {
echo $row["desc_c"] ;

// Free resultset

// Closing connection

Question by:fsze88
1 Comment
LVL 16

Accepted Solution

dr_dedo earned 2000 total points
ID: 20756480
is your data stored well in your tables ? if so, and you cant show them right, use this after macting connection with db
mysql_query( 'SET CHARACTER SET utf8', $link );

it will work if your data are stored as unicode characters

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question