I'm having trouble making this XML file recognize greek characters. When I run it on the browser, the greek characters will appear as questionmarks. I've been trying to fix this for hours now, but I can't find a solution. I use notepad++ with UTF-8 encoding and choosing this type of encoding doesn't make a difference. I've also added the first html lines that are supposed to change the coding to UTF-8 but still nothing happens. This code is a slightly modified version of this tutorial. https://developers.google.com/maps/articles/phpsqlajax_v3#echoxml to match my db columns. I really wouldn't have posted if I wasn't completely stuck.
Any help would be greatly appreciated. Thank you.
<?xml version="1.0" encoding="UTF-8"?> <html> <head> <meta http-equiv="Content-Type" content="text/xml; charset = UTF-8" /> </head> <?php require("phpsqlajax_dbinfo.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('<','<',$htmlStr); $xmlStr=str_replace('>','>',$xmlStr); $xmlStr=str_replace('"','"',$xmlStr); $xmlStr=str_replace("'",''',$xmlStr); $xmlStr=str_replace("&",'&',$xmlStr); return $xmlStr; } // Opens a connection to a MySQL server $connection=mysql_connect ('localhost', 'root', ''); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM array1 WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml "); echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'content ="' . parseToXML($row['content']) . '" '; echo 'type="' . $row['type'] . '" '; echo 'longitude="' . $row['longitude'] . '" '; echo 'latitude="' . $row['latitude'] . '" '; echo '/>'; } // End XML file echo '</markers>'; ?> </html>
No comments:
Post a Comment