I made a dummy xml using my tables.
<?php
header("Content-Type: text/xml");
$output = '<rss version="2.0"><channel>';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$connect = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connect) {
die('Could not connect: ' . mysql_error());
}
$dbname = 'test';
mysql_select_db($dbname);
//set the content type to xml
$sql = mysql_query("SELECT * FROM content");
$output .="
<title> Name of your site </title>
<description> A description of your site </description>";
while($row = mysql_fetch_array($sql)){
$catname = strip_tags($row['CO_NAME']);
$link = $row['CO_ANNOUNCE'];
$description = htmlentities(strip_tags(substr($row['CO_DESCRIPTION'],0,600)));
$output .= "
<item>
<title>$catname</title>
<link>$link</link>
<description>$description</description>
</item>";
}
$output .= '</channel></rss>';
echo $output;
?>
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
Make sure you don't output anything before the header function. Even a whitespace before header can cause this warning.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
There is one BIG white space before <?php . :)
Try this.
<?php
header("Content-Type: text/xml");
$output = '<rss version="2.0"><channel>';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$connect = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connect) {
die('Could not connect: ' . mysql_error());
}
$dbname = 'rss';
mysql_select_db($dbname);
//set the content type to xml
$sql = mysql_query("SELECT * FROM article");
$output .="
<title> Name of your site </title>
<description> A description of your site </description>";
while($row = mysql_fetch_array($sql)){
$catname = strip_tags($row['title']);
$link = $row['link'];
$description = htmlentities(strip_tags(substr($row['body'],0,600)));
$output .= "
<item>
<title>$catname</title>
<link>$link</link>
<description>$description</description>
</item>";
}
$output .= '</channel></rss>';
echo $output;
?>
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
No. Its okay.. Even I have little knowledge on rss feeds. :( Maybe someone else could shed some light on this one.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356