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 :: Unread Messages :: Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
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 06:11 Go to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 06: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 18: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
remove from buddy list
ignore all messages by this user
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] Wed, 22 August 2007 20:26 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 09: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
remove from buddy list
ignore all messages by this user
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] Thu, 23 August 2007 20:17 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 12: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
remove from buddy list
ignore all messages by this user
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 12:47 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 19: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
remove from buddy list
ignore all messages by this user
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 19:38 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 14: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
remove from buddy list
ignore all messages by this user
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] Tue, 28 August 2007 20:19 Go to previous messageGo to next message
nectar2 is currently offline  nectar2   China
Messages: 26
Registered: April 2005
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 19:12 Go to previous message
Ilia is currently offline  Ilia   
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Have you tried re-typing the name while in utf8 mode?

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

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

Current Time: Tue Oct 04 19:31:30 EDT 2022

Total time taken to generate the page: 0.00944 seconds