Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: open

Message Too Old, No Replies

MySQL with UTF-8 Characters

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

Preferred Member

10+ Year Member

joined:Aug 12, 2005
posts:411
votes: 0


Hello,

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:

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

Any ideas?

Thanks

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 21, 2003
posts:1069
votes: 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">

JAG

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

Preferred Member

10+ Year Member

joined:Aug 12, 2005
posts:411
votes: 0


Thanks,

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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members