I've created a table containing certain international characters along with the associated code (ie: 130 | é) so that I can automatically replace them in HTML content as it is being inserted into another table.
The variable $BodyText contains the HTML but for some reason that's probably obvious (though I'm not seeing it), the characters are being replaced by , or other characters that are not even in the table. This line:
$CharacterCode = "&#" . trim($row('CharacterCode')) . ";";
seems to be the culprit. I tried escaping the ; and & but then it inserts the escape character WITH the , or other character. What I am I doing wrong?
Don
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
Code:
$result = mysql_query('SELECT CharacterName, CharacterCode FROM charactercodes');
while ($row = mysql_fetch_row($result)) {
$CharacterName = $row('CharacterName');
$CharacterCode = "&#" . trim($row('CharacterCode')) . ";";
$BodyText = str_replace($CharacterName, $CharacterCode, $BodyText);
}
The variable $BodyText contains the HTML but for some reason that's probably obvious (though I'm not seeing it), the characters are being replaced by , or other characters that are not even in the table. This line:
$CharacterCode = "&#" . trim($row('CharacterCode')) . ";";
seems to be the culprit. I tried escaping the ; and & but then it inserts the escape character WITH the , or other character. What I am I doing wrong?
Don
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases