FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » How to read Chinese characters from MySQL database (puzzle me on stor and read character using FUDforum)
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to read Chinese characters from MySQL database [message #38652] Wed, 22 August 2007 10:11 Go to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
Dear,

I did these:


  1. Installed latest FUDform with chinese language
  2. Set utf8 via 'MySQL Charset Changer'
  3. Everything looks like fine, FUDforum's interface is Chinese and I can post or read via broswer
  4. Then login phpMyAdmin to see whether it is ok on the MySQL side
  5. 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
  6. 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 #38698 is a reply to message #38652] Wed, 22 August 2007 22:22 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The changer changes the charset and the collation of the table(s), but it cannot change the existing data within those tables.

FUDforum Core Developer
Re: How to read Chinese characters from MySQL database [message #38699 is a reply to message #38652] Thu, 23 August 2007 00:26 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
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 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
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
Re: How to read Chinese characters from MySQL database [message #38721 is a reply to message #38717] Fri, 24 August 2007 00:17 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
Thanks for your reply, Ilia.

1. It is exist (forum) information display as ????? (manual add before via phpMyAdmin as utf8 encode)on adm/admforum.php

2. It is already set 'charset=utf-8' at admpanel.php
source of /adm/admpanel.php

<head>
<link rel="StyleSheet" href="adm.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=<?php 
if (file_exists($DATA_DIR.'thm/'.$usr->theme_name.'/i18n/'.$usr->lang.'/charset')) {
	echo trim(file_get_contents($DATA_DIR.'thm/'.$usr->theme_name.'/i18n/'.$usr->lang.'/charset'));
} else if (file_exists($DATA_DIR.'thm/default/i18n/'.$usr->lang.'/charset')) {
	echo trim(file_get_contents($DATA_DIR.'thm/default/i18n/'.$usr->lang.'/charset'));
} else {
	echo 'us-ascii';
}
?>">
</head>


Output of /adm/admforum.php
<head>
<link rel="StyleSheet" href="adm.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

Re: How to read Chinese characters from MySQL database [message #38756 is a reply to message #38721] Sun, 26 August 2007 16:44 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Is the info displayed as ???? new or old, meaning was it added before or after charset change?

FUDforum Core Developer
Re: How to read Chinese characters from MySQL database [message #38759 is a reply to message #38756] Sun, 26 August 2007 16:47 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
Thanks for your replay, Ilia.

It was display as ????? after charset change.
Re: How to read Chinese characters from MySQL database [message #38785 is a reply to message #38759] Mon, 27 August 2007 23:15 Go to previous messageGo to next message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Have you tried changing the charset in the browser to BIG-5?

FUDforum Core Developer
Re: How to read Chinese characters from MySQL database [message #38786 is a reply to message #38785] Mon, 27 August 2007 23:38 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
Thanks for your replay, Ilia.

It is the same after changing the charset in the browser(Opera and Firefox) to BIG-5.
Re: How to read Chinese characters from MySQL database [message #38790 is a reply to message #38786] Tue, 28 August 2007 18:48 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Can you also try the GB2312 charset as well.

FUDforum Core Developer
Re: How to read Chinese characters from MySQL database [message #38792 is a reply to message #38790] Wed, 29 August 2007 00:19 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
Thanks for your replay, Ilia.

I did these:

utf8 charset: Category name is fine, but forum name(and description) not.

big5 charset: Category name isn't fine, and forum name(and description) too.

gb2312 charset: Category name isn't fine, and forum name(and description) too.

gbk charset: Category name isn't fine, and forum name(and description) too.
Re: How to read Chinese characters from MySQL database [message #38814 is a reply to message #38792] Wed, 29 August 2007 23:12 Go to previous message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Have you tried re-typing the name while in utf8 mode?

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Web Site Integration
Next Topic: Mailman to FUDforum
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 00:10:33 GMT 2024

Total time taken to generate the page: 0.02350 seconds