Forum Moderators: coopster

Message Too Old, No Replies

Displaying International Characters from mysql

         

matt45

1:21 am on Aug 15, 2006 (gmt 0)

10+ Year Member



I have a database with international characters and they display perfectly in phpmyadmin. However they come up as a "?" (question mark) when I try to call them in my pages. I have the encoding set to:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

which is the same as phpmyadmin. What am I doing wrong?

alexorig

2:31 am on Aug 15, 2006 (gmt 0)

10+ Year Member



You are right asking the question here I think this is a php issue which is described well on the php site.

When you read the data from mySQL you probably want to use utf8_decode() and then before writing it out you want to use utf8_encode(). Both of these are supported in PHP4 and 5. There are better solutions (by changing the internal coding of the php program) which hopefully someone on this board can explain to both of us but the only way I have been able to handle UTF8 encoding is to play around with those functions and the examples shown on the php website.

Hope this helps.

matt45

2:37 am on Aug 15, 2006 (gmt 0)

10+ Year Member



Thanks, a quick $var = utf8_encode($mysqldata); solved the problem.

alexorig

4:36 am on Aug 15, 2006 (gmt 0)

10+ Year Member



no probs, I am a true lover of a. PHP and b. anyone who cares enough to do UTF-8 encoding. That wins big points in my book :) the web is for everyone!

coopster

1:40 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, matt45.

alexorig, are you referring to the possibility of changing the default_charset [php.net]?