getting the problem ~
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /studhome/1/0803087/public_html/RSS.php on line 14

trying to create a RSS feed
no idea what is wrong, so can anyone help

<?
// Connect to database
DEFINE ('DB_USER', '******'); 
DEFINE ('DB_PASSWORD', '********'); 
DEFINE ('DB_HOST', '*****'); 
DEFINE ('DB_NAME', '******');

// Get latest items from db
$sql = "SELECT Name FROM Games ORDER BY date_added DESC limit 0,10";
$rst = mysql_query($sql);

// Loop through data and build feed items
$items = "";
while($a_row = mysql_fetch_assoc($rst))
{
$items.= "<item>";
$items.= " <title>{$a_row['title']}</title>";
$items.= " <link>{$a_row['link']}</link>";
$items.= " <description>{$rst['description']}</description>";
$items.= "</item>"; 
}

// Build feed text
$feed = "<?xml version=\"1.0\"?>";
$feed.= "<rss version=\"2.0\">";
$feed.= " <channel>";
$feed.= " <title>My cool feed</title>";
$feed.= " <link>http://www.dude.com/</link>";
$feed.= " <description>A cool feed</description>";
$feed.= " $items";
$feed.= " </channel>";
$feed.= "</rss>";

// Display feed text
echo $feed;
?>

Recommended Answers

You have to establish a connection first with mysql_connect().
Try

$rst = mysql_query($sql) or die(mysql_error());

to learn more about the problem.

Jump to Post

All 2 Replies

You have to establish a connection first with mysql_connect().
Try

$rst = mysql_query($sql) or die(mysql_error());

to learn more about the problem.

Thanks! Duhhh that helped, i actually put that in, then took it out for some reason. Amateur mistake :yawn:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.