Hello,

I need some help.

I have a MySql DB, and some fields have Japanese values.

DB collate is set to: utf8_general_ci

When I check for a specific register with PhpMyAdmin, values with japanese characters display ok, but when I try to get the same register to show it using php I got "???" characters. I have tried everything and still without solving this. here is my code:

<?php
	header("Content-type: text/html; charset=utf-8"); 

	include("core/scripts/db_connection.php");
	
	$query	= "SELECT `logdownloadid`, `stitle` FROM `downloadstats` WHERE `country` = 'CHINA'";
	$result	= mysql_query($query);
	

?>
<html>
	<head>
		 
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		 
		<title>Radio and Television Service Statistics </title>

		<link rel="stylesheet" href="core/css/default2.css" 	type="text/css" media="screen"/>
		
		<?php
			while($row = mysql_fetch_array($result))
			{
                                echo $row[0]." : ".$row[1]."<br>";
				echo $row[0]." : ".utf8_encode($row[1])."<br>";
				echo $row[0]." : ".htmlentities($row[1], ENT_QUOTES, 'UTF-8')."<br>";
			}
		?>
		
	</head>
	<body>
	</body>
</html>

The JAPANESE characters doesn't display well using utf8_encode nor htmlentities.

HELP!!!

Recommended Answers

All 3 Replies

Set the connection character set to utf-8, too.
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
or
mysql_set_charset( "utf-8" );

Thanks!!!!

I have guessed that I was missing that part, but I didn't knew how to set it up.

Now, it is working properly.

Thank you so much!

Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.