Welcome to WebmasterWorld Guest from 54.227.83.19

Forum Moderators: open

Message Too Old, No Replies

MySQL with UTF-8 Characters

     

Jeremy_H

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

10+ Year Member



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

justageek

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

WebmasterWorld Senior Member 10+ Year Member



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

Jeremy_H

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

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month