Ask a Question related to PHP Development, Design and Development.
-
Wayne... #1
help with rss creating code creating an XML rss feed]
When I run the following code [which is my 1st attempt at creating XML from
a mysql database, eventualy this will become an RSS feed] I get the follwing
error and cant really see the problem I am incxluding this file from another
page
thanks in advance
Wayne...
ERROR I GET: [if I run from test.php]
----------------
Only one top level element is allowed in an XML document. Error processing
resource 'http://localhost/index.php'. Line 2, Position 2
<br />
-^
-------------------
ERROR [if I run directly - meaning this is probably the problem area]
-------------------
Only one top level element is allowed in an XML document. Error processing
resource 'http://localhost/test.php'. Line 3, Position 2
<b>Warning</b>: Cannot modify header information - headers already sent by
(output started at c:\inetpub\wwwroot\test.php:2) in
<b>c:\inetpub\wwwroot\test.php</b> on line <b>4</b><br />
-^
------------------
CODE [test.php]
-------------------
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "root";
$pass = "******";
$database = "rssdb";
$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 myarticles ORDER BY date DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<entries>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<entry>\n";
$xml_output .= "\t\t<date>" . $row['date'] . "</date>\n";
// Escaping illegal characters
$row['content'] = str_replace("&", "&", $row['content']);
$row['content'] = str_replace("<", "<", $row['content']);
$row['content'] = str_replace(">", ">", $row['content']);
$row['content'] = str_replace("\"", """, $row['content']);
$xml_output .= "\t\t<content>" . $row['content'] . "</content>\n";
$xml_output .= "\t</entry>\n";
}
$xml_output .= "</entries>";
echo $xml_output;
?>
Wayne... Guest
-
Creating rss feed with Coldfusion
Hi, I'm getting the following xml errorswhen I'm trying to do this, can anybody help? ----error---- XML Parsing Error: xml processing... -
Creating an RSS feed
Has anyone created an rss feed? I need help. My RSS feed validates at feedvalidator.org but will not display in Mozilla. currently the file name... -
ADVICE: Need sheet feed scanner for creating Word doc's w/Acrobat
I need to scan about 1000 pages of mostly text, to be converted to Word documents and ultimately imported into InDesign. I have a flatbed scanner and... -
Creating DataGrid Via Code...
Hey all, Been reading up on ASP.NET (using VB.NET) and have been trying to figure out if this is possible. I need to make 4 connections to 4... -
creating on-the-fly asp:table in the code file
Hi, I dont know it is doable, but I wanna ask it anyway. I am pulling 5 different data from a datatable row by row. So each row has 5 fields...



Reply With Quote

