I want to replace all £ to its HTML code £ => £ because it shows up as a ? in a diamond.
I am using the following code but it does nothing.
<?php
include ("config.php");
$get_id = mysql_real_escape_string($_GET['id']);
$page_get = mysql_query("SELECT * FROM contents_page WHERE `id` = '$get_id'");
while($page_row = mysql_fetch_assoc($page_get)) {
$page_row["Page_Content"] = str_replace('£','£',$page_row[Page_Content]);
$smarty->assign('page_title', $page_row['Page_Title']);
$smarty->assign('page_content', $page_row['Page_Content']);
}
$smarty->display('page.tpl');
?>
I am using str_replace() but nothing happens its like it cannot see the £
I had an encoding problem myself. Go to the database and see if the data is being garbled or not. if it is not, then set your connection attributes like this SET CHAR UTF8 before you connect to the database..
The other solution is to see to what the input was encoded before it went to the database, and then change the charset to that
mysql_set_charset(‘latin1’,$link2);
for example.
Any way, what I would do, I would still set my chars to utf-8 , output the results to the page.. see if the character is actually a pound sound, if it is a different symbol, I would put it in the string replace function instead of the pound symbol