Hi,
I'm doing some work for a German website. They want to be able to type in characters for which there are HTML entities like
. The plain text should be stored in a database so it can be later retrieved and read into an XML file. The XML file is read by a Flash file to create a news ticker.
Unfortunately the ticker is displaying some characters incorrectly. I thought that you would need to use html_entities when writing to the database, html_entity_dec ode when reading from it and the ISO encoding in the XML file. Could anyone tell me where I'm going wrong.
Thanks,
Sean
I'm doing some work for a German website. They want to be able to type in characters for which there are HTML entities like
Code:
Ü ü ä
Unfortunately the ticker is displaying some characters incorrectly. I thought that you would need to use html_entities when writing to the database, html_entity_dec ode when reading from it and the ISO encoding in the XML file. Could anyone tell me where I'm going wrong.
Code:
// Writing to the database.
$sql = "UPDATE news SET title = " . '"' . htmlentities( addslashes($_POST['title']), ENT_QUOTES, 'ISO-8859-1' ) . '"' . ", article = " . '"' .
addslashes($_POST['article']) . '"' . ", summary = " . '"' . addslashes($_POST['summary']) . '"';
if(isset($filename1)) $sql .= ", image_file = '$filename1' ";
$sql .= "WHERE news_id = {$_POST['articleId']}";
// Reading from the database.
$sql = "SELECT * FROM news ORDER BY news_id DESC";
$result = $con->sqlExecute($sql);
$xmlContent = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
$xmlContent .= "<ticker>\n";
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
$xmlContent .= "<topic>\n";
$xmlContent .= "<text><![CDATA[<font size=\"12px\" color=\"#624A9E\"><b>" . html_entity_decode( $row['title'], ENT_QUOTES, 'ISO-8859-1' ) . "</b></font><br /><font size=\"12px\" color=\"#686868\">$row['summary'] )...</font><br /><font size=\"12px\" color=\"#624A9E\"><b>Read more</b></font>]]></text>\n";
$xmlContent .= "<link>NewsDetail.php?news_id={$row['news_id']}</link>\n";
$xmlContent .= "<targetIsUrl>Y</targetIsUrl>\n";
$xmlContent .= "</topic>";
}
// First line of XML.
<?xml version="1.0" encoding="ISO-8859-1"?>
Sean
Comment