使用PHP 4从数据库输出XML

I need to get XML output file with PHP 4 (I know that it is easier using php 5 but at this point I cannot upgrade it in our company) The data is extracted from a MySQL database.

Here is a code snippet I wrote but it is not working.

<!DOCTYPE HTML> 
<html>
<body>
<?php

  // Establish db connection

  require_once ('config.php');

  $sql= "SELECT * FROM GeneralProperty
  WHERE fname= '".$_POST["fname"]."' AND target= '".$_POST["target"]."'";
  $result=mysql_query($sql)
  OR die ("Error: $sql <br>".mysql_error());

  header('Content-type: text/xml');
  header('Pragma: public');
  header('Cache-control: private');
  header('Expires: -1');
  echo '<?xml version=\"1.0\" encoding=\"utf-8\"?>';

  echo '<xml>';
  while ($row =mysql_fetch_array($result))
  {
      echo '<Feature>';
      echo '<featureName>' .'Feature Name (FAJ xxxx/x):'. '</featureName>';
      echo '<f>'. $row['fname'].'</f>';
      echo '</Feature>';
  }
  echo '</xml>'; 
  ?>  
  </body>
  </html>