PhpDig.net

Go Back   PhpDig.net > General Forums > Coding & Tutorials

Reply
 
Thread Tools
Old 02-16-2005, 10:44 AM   #1
Edomondo
Orange Mole
 
Edomondo's Avatar
 
Join Date: Jan 2004
Location: In outer space
Posts: 37
Storing UTF-8 in MySQL

I'm facing a problem about storing UTF-8 encoded character in MySQL.
I've googled around and many persons are having the same problem.

One of my page is UTF-8 encoded. It contains text fields whose content are stored to MySQL.
When I enter Japanese character in the box, they are not stored the correct way (either characters like メーãƒâ€*ルレジェンド 交響詩 宿命 or question marks ????????????????).
The problem is that PhpDig does store unicode character in MySQL very well! I've looked at its code but found no clues.
I've tried with utf8_encode & utf8_decode, htmlentities... but nothing worked.

Please help :-(
Edomondo is offline   Reply With Quote
Old 02-17-2005, 02:16 AM   #2
renehaentjens
Orange Mole
 
Join Date: Nov 2003
Posts: 69
Works OK for me

I did a test with a HTML-page containing a TEXTAREA. The page was generated by PHP, with: header('Content-Type: text/html; charset=UTF-8');

I could input letters with accents and Greek letters. They came back correctly after having been stored in MySQL, retrieved back, and displayed again in a new UTF-8 HTML-page.

My test was with the Firefox 1.0 browser and an EasyPHP 1.7 (Windows) server, which is PHP 4.3.3 and MySQL 4.0.15. The tables in MySQL were created with all defaults in an 8859-1 environment.

Of course, if you look in the MySQL tables, e.g. with phpMyAdmin, the data looks bizarre because with this DB setup MySQL doesn't "know" that it is storing UTF-8, it just stores octet-strings. But for getting user input and re-displaying it, that doesn't matter.
__________________
René Haentjens, Ghent University
renehaentjens is offline   Reply With Quote
Old 02-17-2005, 02:35 AM   #3
Edomondo
Orange Mole
 
Edomondo's Avatar
 
Join Date: Jan 2004
Location: In outer space
Posts: 37
Thank you for your reply.

I've tried to display a UTF-8 content stored to MySQL by PhpDig and the result was OK, so my problem must come from the storing process.

I've set the default charset of my tables to UTF-8 (just like PhpDig does), but still can't figure why it works for PhpDig and not for me...

Any clue?
Edomondo is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
UTF-8 support Zebulon Mod Requests 0 12-05-2006 07:38 AM
UTF-8 Question jackpod How-to Forum 4 09-22-2006 06:10 PM
utf-8 pages djuritz How-to Forum 2 07-02-2006 12:03 PM
other UTF-8 languages miladmovie How-to Forum 1 02-08-2005 10:28 AM
utf-8 support kozlovsk How-to Forum 1 10-27-2004 05:56 AM


All times are GMT -8. The time now is 12:08 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.