im getting an error and it wont show items <b>Warning</b>: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in <b>/usr/home/public_html/rss.php</b> on line <b>64</b><br /> Code (markup): Help! <?php ################################################ # # # SRSSS - Simple RSS Script # # Version 1.5 - 2007-02-11 Florian Beer # # # # Dieses Script steht unter der MDWDW Lizenz. # # Die 'Mach doch was du willst' Lizenz. # # Viel Spass damit! # # # ################################################ // RSS Setup $title = 'My Homepage'; $link = 'http://www.myhomepage.com'; $description = 'This is the feed from my homepage'; $encoding = 'iso-8859-1'; $lang = 'de-at'; // DB Setup $host = "localhost"; $user = "root"; $pass = ""; $db = "myDBname"; $query = "SELECT * FROM quotes ORDER BY ID DESC LIMIT 10"; $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); mysql_select_db($db, $connection) or die ("Unable to select database!"); $result = mysql_query($query); function convTimestamp($date){ $year = substr($date,0,4); $month = substr($date,4,2); $day = substr($date,6,2); $hour = substr($date,8,2); $minute = substr($date,10,2); $second = substr($date,12,2); $stamp = mktime($hour, $minute, $second, $month, $day, $year); return $stamp; } header('Content-type: application/rss+xml'); echo '<?xml version="1.0" encoding="'.$encoding.'"?>'; echo "\n"; echo '<rss version="2.0">'; echo "\n"; echo '<channel>'; echo "\n"; echo "\n"; echo '<title>'.$title.'</title>'; echo "\n"; echo '<link>'.$link.'</link>'; echo "\n"; echo '<description>'.$description.'</description>'; echo "\n"; echo '<lastBuildDate>'.date("D, d M Y H:i:s").' +0000</lastBuildDate>'; echo "\n"; echo '<language>'.$lang.'</language>'; echo "\n"; echo "\n"; // Loop through all items // substitute with your DB values while($row = mysql_fetch_object($result)){ $stamp = convTimestamp($row->timestamp); echo '<item>'; echo "\n"; echo ' <title>'.$row->title.'</title>'; echo "\n"; echo ' <link>'.$link.$row->ID.'</link>'; echo "\n"; echo ' <guid>.'$link.$row->ID.'</guid>'; echo "\n"; echo ' <pubDate>'.date("D, d M Y H:i:s", $stamp).' +0000</pubDate>'; echo "\n"; echo ' <description>'.$row->text.'</description>'; echo "\n"; echo '</item>'; echo "\n"; } echo "\n"; echo '</channel>'; echo "\n"; echo '</rss>'; ?> Code (markup):
the line below is wrong echo ' <guid>.'$link.$row->ID.'</guid>'; Code (markup): it should be echo ' <guid>'.$link.$row->ID.'</guid>'; Code (markup): except this... if you have that table called quotes and the proper fields in that table.. then it should work. I hope this one helps
I was going to say its the query, I think you need to do it this way. $result = mysql_query("$query"); Or if that's still falling just write it out: $result = mysql_query("SELECT * FROM quotes ORDER BY ID DESC LIMIT 10");
Perhaps you should transmit MySQL connection link identifier toward mysql_query: $result = mysql_query($query); Code (markup): Change to: $result = mysql_query($query, $connection); Code (markup): Let us know if it helped you.