Ice Rainbow , Click to back to blog home .
When you thinking of me , is the time when I missing you ...
Web DevelopmentPMComments (0) • Trackbacks (0) • Full article

Mutibyte Charactor BUG in almost Europe&USA PHP Apps

There is a BIG BUG when Chinese users using lots of Europe PHP Applications . Most of them work with mySQL database , and they works very well too . But in mySQL 4.1 update , it adds a new feture to sopport muti languages . That makes PHP code different than before . If it still use the codes before , It will take lots of problems . First , when all database , tables and fields encoding is lattin_swedish_ci , and data encoding is utf8 , You can’t see any wrong in your system , it looks work very good and strong . If you are using mySQL 4.1 and working on Chinese or other mutibyte languages , now you can open the database with any tools (like phpMyAdmin ) To see data in Chinese , NOBODY can read them .Second , when all database , tables and fields encoding is utf8_gerneral_ci , and data encoding is utf8 , Now you try insert “恐怖” this two Chinese charactors in your system , when you read them from your system , it will be changed , also , nobody know what’s meaning of them . this is also seen in database .OK , if this problem just can’t read the data in phpMyAdmin or other database tools , it is not a problem , BUT , when we try to make a sql dump file , and restore them , the problem comes . You can’t get a right database and you can’t restore data to database anyway .we also find this bug in a Ajax forums applacation Vanilla , the fix solution is very easy . Once you connect to database , add a SET NAMES query to database . That’s all !

eg.

This is some code from Vanilla , it have mutibyte encoding problem :

$this->Connection = @mysql_connect($this->Context->Configuration['DATABASE_HOST'],
$this->Context->Configuration['DATABASE_USER'],
$this->Context->Configuration['DATABASE_PASSWORD']);

To fix it is very easy :

$this->Connection = @mysql_connect($this->Context->Configuration['DATABASE_HOST'],
$this->Context->Configuration['DATABASE_USER'],
$this->Context->Configuration['DATABASE_PASSWORD']);
@mysql_query('SET NAMES "utf8"', $this->Connection);]

Fei 2006 - 08 - 20
DailyPMComments (0) • Trackbacks (0) • Full article

Swimming at Saturday evening .

I have gone swimming with 3 girls at Saturday evening , one of them is very sweet ! But it is often extreme joy begets sorrow , I hurt my arms . :(

Fei 2006 - 08 - 19
Page 1 , Total 1 pages .
Copyright © icebird , 2006-2009