the following code runs a query on a database and outputs the results as XML within its self. I have attempted to get the php page to create a file called rss.xml but have failled. I have tried using $file= fopen("rss.xml" , "w"); but my knowlege of PHP wouldn't be the best or anyway near to the level of being able to modify the below page to do as i wish, would someone be able to take a peep at the page please?
<?
header("Content-type: text/xml");
$host = "***********";
$user = "***********";
$pass = "***********";
$database = "***********";
$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 mynews ";
$result = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
$xml_output .= "<entries>\n";
for ($x = 0; $x < mysql_num_rows($result) ; $x++){
$row = mysql_fetch_assoc($result);
$xml_output .= "\t<player>\n";
$xml_output .= "\t\t<name>" . $row['title'] . "</name>\n";
$xml_output .= "\t\t<pos>" . $row['message'] . "</pos>\n";
$xml_output .= "\t\t<dob>" . $row['user'] . "</dob>\n";
$xml_output .= "\t\t<apps>" . $row['content'] . "</apps>\n";
// Escaping illegal charcters
$row ['text'] = str_replace("&", "&", $row['text']);
$row ['text'] = str_replace("<", "<", $row['text']);
$row ['text'] = str_replace(">", ">", $row['text']);
$row ['text'] = str_replace("\"", ""e", $row['text']);
$xml_output .= "\t\t<text>" . $row['text'] . "</text>\n";
$xml_output .= "\t</player>\n";
}
$xml_output .= "</entries>";
print $xml_output;
?>