homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

MySQL with UTF-8 Characters

 1:41 am on Dec 23, 2006 (gmt 0)


I have a MySQL table that contains UTF-8 Characters.

Unfortunately, when I insert contents from my table into my web pages, non ASCII characters are being shown as boxes.

All my pages are properly encoded using the UTF-8 Chartype. If I paste these characters directly into my page, the characters show fine.

The MySQL table has a default Collation of utf8_unicode_ci, and the text cells also have the same collation.

In PhpMyAdmin, when viewing the tables, the characters show properly.

Right now, the only guess I have is that maybe my weak point is when I use PHP to grab the contents form my table and insert them into the page.

I use the following code:

$result=mysql_query("SELECT * FROM table_name WHERE x='$x'");
echo $row["article"];

Any ideas?




 3:24 pm on Dec 23, 2006 (gmt 0)

It could be that you don't send the encoding type as UTF-8 in your web page. Make sure you have the following in your html: <meta http-equiv="content-type" content="text/html; charset=UTF-8">



 4:11 pm on Dec 23, 2006 (gmt 0)


I have declaired that line of code, and my .php is also saved as with the right type of encoding. (One even without a BOM [webmasterworld.com]).

I have tried the following line in the same php document:

echo "René Descartes"; and it works fine, which tells me PHP can handle non ASCII characters.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved