Hi there I am trying to emulate a xml text file. I am presuming that if I do everything correctly the below php file will display in firefox the same way a xml text file would. i.e. showing the structure of the xml.
[COLOR=DarkOrange]This is the file I copied from the tutorial as per the title of this post.[/COLOR]
<?php
$host = "localhost";
$user = "root";
$pass = "";
$database = "test";
$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 articles ORDER BY id DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<entries>
";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= " <entry>
";
$xml_output .= " <date>" . $row['created_at'] . "</date>
";
// Escaping illegal characters
$row['text'] = str_replace("&", "&", $row['body']);
$row['text'] = str_replace("<", "<", $row['body']);
$row['text'] = str_replace(">", ">", $row['body']);
$row['text'] = str_replace("\"", """, $row['body']);
$xml_output .= " <text>" . $row['text'] . "</text>
";
$xml_output .= " </entry>
";
}
$xml_output .= "</entries>";
echo $xml_output;
?>
This is how my browser display’s it (both firefox and safari):
[COLOR=Teal] 2005-10-12 20:30:19 gidday luv 2005-10-12 20:29:28 here i am again 2005-10-12 20:27:34 hello [/COLOR][COLOR=DarkOrange]
[COLOR=Black]where-as view source looks like this: (which is what I want to display in browser)
[/COLOR][/COLOR]
<?xml version="1.0"?>
<entries>
<entry>
<date>2005-10-12 20:30:19</date>
<text>gidday luv</text>
</entry>
<entry>
<date>2005-10-12 20:29:28</date>
<text>here i am again</text>
</entry>
<entry>
<date>2005-10-12 20:27:34</date>
<text>hello</text>
</entry>
</entries>
any help would be great! :q: