How to read Chinese characters from MySQL database [message #38652] |
Wed, 22 August 2007 10:11 |
nectar2
Messages: 26 Registered: April 2005
Karma: 0
|
Junior Member |
|
|
Dear,
I did these:
- Installed latest FUDform with chinese language
- Set utf8 via 'MySQL Charset Changer'
- Everything looks like fine, FUDforum's interface is Chinese and I can post or read via broswer
- Then login phpMyAdmin to see whether it is ok on the MySQL side
- Browse to 'fud26_forum', there are some characters which can be read by human (as attachment show) on 'name' and 'descr' column, and it should be typed Chinese characters
- Used 'mysqldump' to export the database, open .sql file with text editor, as the same previously
Question:
1. What can 'MySQL Charset Changer' do? Just set exist table to specify collation? Is it possible using 'set names(utf8)' to solve this problem?
2. When I tried to modify the un-read characters to be read via phpMyAdmin, FUDforum display modified characters as '????'
(member) post Chinese characters[read] => (FUDforum) submit to MySQL=> (MySQL) store data[un-read] => (FUDforum) display Characters to visitor[read]
[Updated on: Wed, 22 August 2007 10:12] Report message to a moderator
|
|
|
|
Re: How to read Chinese characters from MySQL database [message #38699 is a reply to message #38652] |
Thu, 23 August 2007 00:26 |
nectar2
Messages: 26 Registered: April 2005
Karma: 0
|
Junior Member |
|
|
Thanks for your replay, Ilia.
I'm a newbie, looks like there are still un-read Chinese characters after set utf8 via 'MySQL Charset Changer'. I searched on Internet, there are some usefulness topic, like http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statem ents.html.
So I tried to change some(add SET NAMES 'UTF8'):
fudforum/index.php
from:
if (!defined('fud_sql_lnk')) {
$connect_func = $GLOBALS['FUD_OPT_1'] & 256 ? 'mysql_pconnect' : 'mysql_connect';
$conn = $connect_func($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD']) or die (fud_sql_error_handler("Initiating $connect_func", mysql_error(fud_sql_lnk), mysql_errno(fud_sql_lnk), "Unknown"));
define('fud_sql_lnk', $conn);
to:
if (!defined('fud_sql_lnk')) {
$connect_func = $GLOBALS['FUD_OPT_1'] & 256 ? 'mysql_pconnect' : 'mysql_connect';
$conn = $connect_func($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD']) or die (fud_sql_error_handler("Initiating $connect_func", mysql_error(fud_sql_lnk), mysql_errno(fud_sql_lnk), "Unknown"));
mysql_query("SET NAMES 'UTF8'");
define('fud_sql_lnk', $conn);
And then, looks like it can safe Chinese characters at MySQL(v4.1+). But there is a still ????? at fudforum/adm/admforum.php, but fudforum/adm/admcat.php is ok.
|
|
|
Re: How to read Chinese characters from MySQL database [message #38717 is a reply to message #38699] |
Thu, 23 August 2007 13:37 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
are the characters pertain to new information into the forum or the old one?
You may want to modify admpanel.php inside adm/ dir to send UTF-8 charset rather then the default ISO-8859-15
FUDforum Core Developer
|
|
|
|
|
|
|
|
|
|
|