SauloA Posted January 28, 2008 Share Posted January 28, 2008 I'm trying to get the data in my database to display in my RSS Feed but there's supposedly an error in my code. My web browser says it's the "mysql_fetch_array()" in my code where it says "while($row = mysql_fetch_array($result))" in the private function getDetails(). I found this code on the net and modified it to suit my needs. Seems like I don't know what I'm doing though. Can someone help me out? Here's the full code I'm using: This is the code that grabs the items for the RSS Feed: <?php class RSS { public function RSS() { require_once ('Connections/mysql_connect.php'); } public function GetFeed() { return $this->getDetails() . $this->getItems(); } private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } private function getDetails() { $colname_rsShops = "1"; if (isset($_GET['stateID'])) { $colname_rsShops = $_GET['stateID']; } $detailsTable = "shop_tbl, state_lookup_tbl"; $this->dbConnect($detailsTable); $query = "SELECT * FROM ". $detailsTable ."WHERE shop_state = ". $colname_rsShops ."AND shop_tbl.shop_approved = 1 AND shop_state = state_lookup_tbl.state ORDER BY shop_tbl.shop_name ASC"; $result = mysql_db_query (DB_NAME, $query, LINK); while($row = mysql_fetch_array($result)) { $details = '<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>Anime Shops In '. $row['full_state'] .'</title> <link>http://www.otakuwanted.com</link> <description>Find And Reveiw Anime Shops Near You At Otaku Wanted. Anime Shops In '. $row['full_state'] .'</description> <language></language> <image> <title></title> <url></url> <link></link> <width></width> <height></height> </image>'; } return $details; } private function getItems() { $colname_rsShops = "1"; if (isset($_GET['stateID'])) { $colname_rsShops = $_GET['stateID']; } $itemsTable = "shop_tbl, state_lookup_tbl"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable ."WHERE shop_state = ". $colname_rsShops ."AND shop_tbl.shop_approved = 1 AND shop_state = state_lookup_tbl.state ORDER BY shop_tbl.shop_name ASC"; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $items .= '<item> <title>'. $row["shop_name"] .'</title> <link>http://www.otakuwanted.com/shopselect.php?shopID='. $row["shop_id"] .'</link> <description></description> </item>'; } $items .= '</channel> </rss>'; return $items; } } ?> This is the code that's supposed to display all code above: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); include("classes/RSS.class.php"); $rss = new RSS(); echo $rss->GetFeed(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/88133-help-with-rss-feed-using-php/ Share on other sites More sharing options...
SauloA Posted January 29, 2008 Author Share Posted January 29, 2008 Is anyone gonna hook me up with a solution to this problem? I'd really appreciate. Quote Link to comment https://forums.phpfreaks.com/topic/88133-help-with-rss-feed-using-php/#findComment-451922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.