hello All!!!
first of all happy new year!!
I’m doing some experiencies in producing trough php a xml file from a wordpress database to read from a flash website
I take this tuto from Jubba!!
my first problem encoding utf=8 its not working
this is my php code:
<?php
header("Content-type: text/xml; charset=utf-8");
$host = 'localhost';
$user = 'myuser';
$pass = '*****';
$database = 'mydb';
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM wp_posts ORDER BY post_date DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
";
$xml_output .= "<entries>
";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= " <entry>
";
$xml_output .= " <date>" . $row['post_date'] . "</date>
";
// Escaping illegal characters
$xml_output .= " <text>" . $row['post_content'] . "</text>
";
$xml_output .= " </entry>
";
}
$xml_output .= "</entries>";
echo $xml_output;
?>
you can check this in real time here
if you check the page source in your browser so will see <?xml version=“1.0” encoding=“utf-8”?>
but the special char are not translated.
If anybody can give me a clue as you see this is very strange, for me its a php thing!!
many thnks