We help IT Professionals succeed at work.

How to read chinese characters from mysql by php4

Kin Fat SZE
Kin Fat SZE asked
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

Watch Question

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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.