Recently I rebuilt my website, and I was using this simple code to grab and fetch data from mysql db as rss:
<?php
$connection = mysql_connect("localhost", "site_user", "1212121") or die (mysql_error()); // 'database_name'
$db = mysql_select_db("site_db", $connection) or die (mysql_error());
$rss_query = @mysql_query("SELECT * FROM jokes where valid = '1' order by id asc LIMIT 0,20");
echo $rss = "<?xml version='1.0' encoding='utf-8' ?>
<rss version='2.0'>
<channel>
<title>site</title>
<link>www.site.com</link>
<description>feed</description>
";
while ($q_rss = mysql_fetch_array($rss_query)) {
$id[] = $q_rss['id'];
$title[] = $q_rss['joketitle'];
$des[] = $q_rss['preview'];
}
$count = count($id);
for ( $i = 0; $i <= $count-1; $i ++) {
echo $r = "
<item>
<title>".$title[$i]."</title>
<link>www.site.com/view.php?byt=".$id[$i]."</link>
<description>...".substr($des[$i],0,70)."</description>
</item>
";
}
echo "
</channel>
</rss>";
?>
regarding the link: www.site.com/view.php?byt=".$id[$i]." it was changed to www.site.com/byt/[id] which id= numbers
the error that appear is :
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/site/public_html/rss.php on line 25
Notice: Undefined variable: id in /home/site/public_html/rss.php on line 32
my php and mysql version are up to date ..