lukeUrtnoedki Posted November 30, 2016 Share Posted November 30, 2016 (edited) ok, then Im stuck on one problem, heres my assignment Your RSS feed is to display these fields: Product Name Product Line Product Scale Product Vendor Product Description Buy Price formatted in US dollarsThe product name of each feed item, is to be a link to a product page. You may choose the format of the remaining item data. I have most of it down, but looked at the available tags and made some guesses, is this ok? <?php header('Content-Type: text/xml'); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <rss version='2.0'> <channel> <title><![CDATA[Assignment 9 - Newsfeed]]></title> <link>http://teamluke.net/</link> <webMaster>[email protected]</webMaster> <description><![CDATA[The trials & Tribulations of Luke Urtnowski as I complete this assignment.]]></description> <language>en-us</language> <image> <title>Luke Urtnowski</title> <url>http://php_class.tea...images/luke.jpg</url> <link>http://php_class.tea...images/luke.jpg</link> <description><![CDATA[The trials & Tribulations of Luke Urtnowski as I complete this assignment.]]></description> </image> <?php require_once('db/conn.php'); try { $stmt = $conn->prepare('SELECT productCode, productName, productLine, productDescription, productVendor, buyPrice FROM `products` WHERE productLine = "Trains" OR productLine = "Vintage Cars" ORDER BY timeStamp ASC LIMIT 10'); $stmt->execute(); if($stmt->rowCount()) { while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<item>'; echo ' <link>http://php_class.teamluke.net/Assignment_9/product.php?Code='.$row['productCode'].'>'; echo ' <title>' . $row['productName'] . '</title>'; echo ' </link>'; echo ' <category>' . $row['productLine'] . '</category>'; echo ' <source>' . $row['productVendor'] . '</source>'; echo ' <description><![CDATA[' . $row['productDescription'] . ']]></description>'; echo ' <Price>' // I looked and couldn't figure out if my code in the while loop makes sence. // Does it to you? .number_format($row['buyPrice'], 2) . '</Price>'; echo '</item>'; } } } catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } ?> </channel> </rss> I looked and couldn't figure out if my code in the while loop makes sence.Does it to you? When i try to validate it, I get soo many errors though... https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fphp_class.teamluke.net%2FAssignment_9%2Frss.php Edited November 30, 2016 by requinix using [code] instead of a rich text paste Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/ Share on other sites More sharing options...
cyberRobot Posted November 30, 2016 Share Posted November 30, 2016 The CDATA stuff isn't needed for the first <title> tag. For the <webMaster> tag, see the example in the RSS 2.0 Specification (https://validator.w3.org/feed/docs/rss2.html). For the second <link> tag (child of <image>), see the note in the RSS 2.0 Specification (https://validator.w3.org/feed/docs/rss2.html#optionalChannelElements). Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539897 Share on other sites More sharing options...
lukeUrtnoedki Posted December 1, 2016 Author Share Posted December 1, 2016 ok, made a few changes and this is where im at. https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fphp_class.teamluke.net%2FAssignment_9%2Frss.php Every error occurred 10- times so the problem is everything in the while loop while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<item>'; echo ' <link>http://php_class.teamluke.net/Assignment_9/product.php?Code='.$row['productCode'].'>'; echo ' <title>' . $row['productName'] . '</title>'; echo ' </link>'; echo ' <category>' . $row['productLine'] . '</category>'; echo ' <source>' . $row['productVendor'] . '</source>'; echo ' <description><![CDATA[' . $row['productDescription'] . ']]></description>'; echo ' <Price>$' .number_format($row['buyPrice'], 2) . '</Price>'; echo '</item>'; } I sort of guessed on what tags to use (out of the ones I can) and I had no idea how to use a tag to describe the price. Thanks for your help thus far Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539903 Share on other sites More sharing options...
cyberRobot Posted December 1, 2016 Share Posted December 1, 2016 Most of the errors refer the tags used within the <item> tag. The available children tags (for <item>) are listed in the RSS 2.0 spec here: https://validator.w3.org/feed/docs/rss2.html#hrelementsOfLtitemgt The specification provides examples on how to use the tags. Note that the <title> tag is a child of <item> and not <link>. And there isn't a tag for <Price>, but you could add that information to the <description> tag. Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539913 Share on other sites More sharing options...
cyberRobot Posted December 1, 2016 Share Posted December 1, 2016 On a related note, did you see the "[help]" links to the right of the errors in the W3C validation page (https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fphp_class.teamluke.net%2FAssignment_9%2Frss.php)? They can help guide you to the solutions. Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539914 Share on other sites More sharing options...
lukeUrtnoedki Posted December 1, 2016 Author Share Posted December 1, 2016 (edited) ok made some corrections. But am having a hard time figuring out this last error https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fphp_class.teamluke.net%2FAssignment_9%2Frss.php Edited December 1, 2016 by lukeUrtnoedki Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539931 Share on other sites More sharing options...
cyberRobot Posted December 1, 2016 Share Posted December 1, 2016 It looks like the feed is technically valid. The last two things (guid and misplaced item) are suggestions. With that said, did you see the help links? guid help: https://validator.w3.org/feed/docs/warning/MissingGuid.html misplaced item help: https://validator.w3.org/feed/docs/warning/MisplacedItem.html Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539932 Share on other sites More sharing options...
lukeUrtnoedki Posted December 1, 2016 Author Share Posted December 1, 2016 Ya, dont understand the warning, Do you see the issue? Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539933 Share on other sites More sharing options...
lukeUrtnoedki Posted December 1, 2016 Author Share Posted December 1, 2016 ok, thanks Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539939 Share on other sites More sharing options...
lukeUrtnoedki Posted December 1, 2016 Author Share Posted December 1, 2016 the warning says to move all item elements to the bottom of the channel, arent they allready? Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539941 Share on other sites More sharing options...
cyberRobot Posted December 2, 2016 Share Posted December 2, 2016 the warning says to move all item elements to the bottom of the channel, arent they allready? Hint: there is a tag in your code after the last <item> tag, but before the end </channel> tag. It rhymes with "batom". Quote Link to comment https://forums.phpfreaks.com/topic/302650-rss-confusion/#findComment-1539968 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.