开发者

Euro sign not showing on site

One of my fields (which is a latin1_swedish_ci) seems to show the euro symbol fine in PHPMYADMIN inside of the field.

However, when I try to echo it in an input field on my website in a form, it shows up as the question-mark in firefox.

Heres the html/php:

$sql = mysql_query("select * from `settings`");

while ($row = mysql_fetch_assoc($sql))
    $setting[$row['field']] = htmlspecialchars($row['value'], ENT_QUOTES);

<input type="text" name="currency_symbol"开发者_高级运维 id="currency_symbol" size="50" value="<?php echo $setting['currency_symbol']; ?>" />

I am using the following meta tag on the page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

I've tried using utf8_general_ci for the field, but I get the same result.


Try using htmlentities() instead of htmlspecialchars().

Special chars does not convert everything, just a few select characters. The Euro symbol €, needs to be encoded really, &euro;.


If you are serving the page as UTF-8, you will need to ensure you grab the string out of the database in the UTF-8 encoding before putting it on the page. You can do that using:

mysql_set_charset('utf8');

(If you're doing that it would also make sense to store your actual table data in UTF-8 too, eg utf8_general_ci, rather than latin1_swedish_ci, so you can deal properly with characters outside of the basic Latin-1 set.)


Try to change the MySQL charset to UTF-8 or to Swedish.

Here it is a small example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜