# Php/xml/encoding="utf-8"

**URL:** <https://forum.kirupa.com/t/php-xml-encoding-utf-8/248169>\
**Category:** Uncategorized\
**Created:** [January 4, 2008, 3:58pm UTC](https://forum.kirupa.com/t/php-xml-encoding-utf-8/248169 "2008-01-04T15:58:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![voxoff](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@voxoff](https://forum.kirupa.com/u/voxoff)\
**Post date:** [January 4, 2008, 3:58pm UTC](https://forum.kirupa.com/t/php-xml-encoding-utf-8/248169/1 "2008-01-04T15:58:23Z")

</div>

hello All!!!  
first of all [happy new year!!](http://blog.brunodasilva.net/?p=41)

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](http://www.kirupa.com/web/mysql_xml_php.htm) from Jubba!!

my first problem encoding utf=8 its not working  
this is my php code:

```php
<?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](http://www.plantazero.com/codelab/sqlxml.php)

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
