Hello all,

I'm generating XML content from a MySQL database using PHP, but occasionally get the XML error: Invalid Character in content.

The weird thing about the error is that it's only in IE6 (Firefox doesn't get the error), and it doesn't always occur! In fact, I can usually refresh the page and the error would disappear (even though I'm still getting the same content from the database).

The relevant code is given below:

PHP Code:
$result mysql_query('select * from '.$table);
header('Content-type: text/xml; charset=windows-1256');
// rows while-loop: Goes through all the rows returned from the database
while($row =  @mysql_fetch_array($result)){
$i 0;
// column while-loop: Determines the number of columns in the table, and gets the data for each column
while($i mysql_num_fields($result)) {
//  echo "Information for column $i:<br />\n";
$meta mysql_fetch_field($result$i);
  if (!
$meta) {
"<error>No information available</error>";
// <![CDATA[". htmlspecialchars($row[$i]) ."]]>
echo "<$meta->name>"htmlspecialchars($row[$i]) ."</$meta->name>";
// end columns while-loop
echo "</row>";
// end rows while-loop
echo "</table>"
Please Note:

* I used htmlspecialchars() when displaying the content, so - technically - there shouldn't be any dubious HTML/XML characters in the content (e.g. &).

* I defined the encoding as windows-1256 because I have some Arabic characters in the database.

* Some of the data contains French characters, like .

Any help will be highly appreciated!