popescuradhoo Posted April 10, 2009 Share Posted April 10, 2009 Hello, I have the following php code that should return a rss page, but the problem is that nothing from my sql data base appears on the rss page. All the connection info are correct. Can you tell me why doesn't return any article?? Thanks <?php $db = new mysqli("localhost", "user", "pass", "site_db"); ?> <?php header('Content-type: text/xml'); ?> <?php echo "<?";?>xml version="1.0" encoding="iso-8859-1"<?php echo "?>";?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>Quantic Lab</title> <link>http://www.quanticlab.com</link> <description>Press Releases</description> <language>en-us</language> <copyright>2009 Quantic Lab</copyright> <pubDate>Tue, 10 Apr 2009 22:31:45 EDT</pubDate> <lastBuildDate>Tue, 10 Apr 2009 22:31:45 EDT</lastBuildDate> <category>Quality Assurance</category> <generator>QL RSS Generator</generator> <ttl>60</ttl> <image> <url>http://www.quanticlab.com/feed/Sigla_alb.jpg</url> <title>Quantic Lab</title> <link>http://www.quanticlab.com</link> <height>95</height> <width>133</width> <description>Quality Assurence</description> </image> <?php $query = "SELECT * FROM news"; $results = $db->query($query); $number = $results->num_rows; for ($i = 1; $i <= $number; $i++) { $row = $results->fetch_assoc(); $title = $row['news_titlu']; $description = $row['news_short']; $link = "http://www.quanticlab.com/press.php?id_news=".$row['id_news']; $date = date("r", $row['timestamp']); ?> <item> <title><?php echo $title; ?></title> <description><?php echo $description; ?></description> <link><?php echo $link; ?></link> <pubDate><?php echo $date; ?></pubDate> <guid><?php echo $link; ?></guid> </item> <?php } ?> </channel> </rss> <?php $db->close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/153453-rss-for-web-site/ Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 Try putting or die(mysql_error()); after every mysql query/connection, see what it does... Oh, sorry you're using mysqli. Not too familiar with that...but do the equivalent Quote Link to comment https://forums.phpfreaks.com/topic/153453-rss-for-web-site/#findComment-806229 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.