Problem displaying Japanese charset (UTF-8) in PHP

bissatch70

New Member
Messages
1
Reaction score
0
Points
0
Hi,

I want to store English and Japanese in a database table which I have managed to achieve by setting the database to UTF-8 (supports both). When I check the table in phpmyadmin the Japanese is there. However, when I extract the Japanese data using a PHP script and display it in the browser it comes out as ???????????????????? - is this because the apache/php server is not set as UTF-8? I have been able to set this in my apache.conf file on my local server on my PC but I doubt I'll have such control from a hosting server which I understand. Is there any method to allow me to display these characters? Can this be set from the x10 cpanel? Or even the PHP script?

Cheers
Bizt
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I've seen plenty of blogs, forums, etc hosted here in non-Western character sets. They all use the same Apache + PHP+MySQL you do.
 

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
Hello

Have you insert this meta tag in your html script ?

HTML:
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
 

tcp_udp12

New Member
Messages
1
Reaction score
0
Points
0
At first, you must set character set in database connection before any SELECT, UPDATE or INSERT query
PHP:
mysql_query( 'SET NAMES utf8' );
then, your site must send data in UTF-8:
encoding of the source files must be UTF-8
and site must send header which inform browser to display your site in UTF-8
PHP:
<?php
header('content-type: text/html; charset=utf-8');
?>
or
HTML:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
 

John Rambo

New Member
Messages
27
Reaction score
0
Points
1
It's a database problem.
Generally one should choose proper charset/collation (utf8/utf8_general_ci) for databases/tables.
If a table has wrong charset/collation you will get questions (????)when you want to write something in it.

In your case it seems you have right charset/collation for tables, as when you see data in pma it's ok. So you should use query, mentioned above to set charset, every time before other queries.
 
Top