May 1, 201412 yr I'm trying to an RSS feed from scratch for a friend's script. The script allows her to post blog posts and updates. However, the script doesn't come with any type of RSS feed set up. So I'm trying to create one for her. However, I'm getting errors. I am trying to connect the database for her current script up with this RSS feed. So it'll use the updates to automatically update the RSS feed. Does that make sense? Anyway, the problem is that I'm getting errors. I don't understand why. First, you can find the RSS Feed's coding at this location: http://pastebin.com/73HhrNQE The error is as following, This page contains the following errors: error on line 38 at column 28: Extra content at the end of the document Below is a rendering of the page up to the first error. Can anyone help?
May 1, 201412 yr Look like error in line 15 echo "<?xml version='1.0' encoding='UTF-8'?--> <rss version="2.0"> String is terminated after version=" You should escape " in version="2.0"
May 1, 201412 yr Author Look like error in line 15 echo "<?xml version='1.0' encoding='UTF-8'?--> <rss version="2.0"> String is terminated after version=" You should escape " in version="2.0" What do you mean 'escape'? I don't understand...
May 2, 201412 yr http://pastebin.com/aTDty30d or: <?php define ("DB_HOST", "localhost"); // set database host define ("DB_USER", "alove_listadmin"); // set database user define ("DB_PASS", "xxxxxxx"); // set database password define ("DB_NAME", "alove_listadmin"); // set database name $link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection."); $db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database"); $query = "SELECT title, description, url FROM ".table_rss." WHERE status=1 ORDER BY created_date desc"; $getBlogDisplay = mysql_query($query); header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>A Love Letter</title> <link>http://aloveletter.co.uk/</link> <description>a fanlisting collective</description> <language>en-us</language>'; while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){ $title = escapeXMLVal( $dataBlogDisplay['uTitle'] ); $link = escapeXMLVal( $dataBlogDisplay['uID'] ); $description = escapeXMLVal( $dataBlogDisplay['uEntry'] ); $date = escapeXMLVal( $dataBlogDisplay['uAdded'] ); echo "<item> <title>$title</title> <pubDate>$date</pubDate> <link>$link</link> <description>$description</description> </item>"; } echo "</channel></rss>"; function escapeXMLVal($xval){ $xval = str_replace('&', '&', $xval); $xval = str_replace('"', '"', $xval); $xval = str_replace('<', '<', $xval); $xval = str_replace('>', '>', $xval); $xval = str_replace("'", ''', $xval); return $xval; } ?>
May 2, 201412 yr http://pastebin.com/aTDty30d Well, I changed my coding to the one you gave and now I have more errors, This page contains the following errors:error on line 38 at column 23: Extra content at the end of the document Below is a rendering of the page up to the first error. http://aloveletter.co.uk/ a fanlisting collective en-us'; while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){ $title = escapeXMLVal( $dataBlogDisplay['uTitle'] ); $link = escapeXMLVal( $dataBlogDisplay['uID'] ); $description = escapeXMLVal( $dataBlogDisplay['uEntry'] ); $date = escapeXMLVal( $dataBlogDisplay['uAdded'] ); echo " $date $link $description "; } echo "
May 2, 201412 yr I don't have access to your db so I can't test mysql, but you are using wrong field names SELECT title, description, url in query and uTitle, uID, uEntry, uAdded in while loop
May 2, 201412 yr SELECT title, description, url in query and uTitle, uID, uEntry, uAdded in while loop ...I have no idea what you're talking about. How do I do this?
May 3, 201412 yr <?php define ("DB_HOST", "localhost"); // set database host define ("DB_USER", "alove_listadmin"); // set database user define ("DB_PASS", "xxxxxxx"); // set database password define ("DB_NAME", "alove_listadmin"); // set database name $link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection."); $db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database"); $query = "SELECT title , description, url, created_date FROM ".table_rss." WHERE status=1 ORDER BY created_date desc"; $getBlogDisplay = mysql_query($query); header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8" ?>'. '<rss version="2.0"> <channel> <title>A Love Letter</title> <link>http://aloveletter.co.uk/</link> <description>a fanlisting collective</description> <language>en-us</language>'; while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){ $title = escapeXMLVal( $dataBlogDisplay['title'] ); $link = escapeXMLVal( $dataBlogDisplay['url'] ); $description = escapeXMLVal( $dataBlogDisplay['description'] ); $date = escapeXMLVal( $dataBlogDisplay['created_date'] ); echo "<item> <title>$title</title> <pubDate>$date</pubDate> <link>$link</link> <description>$description</description> </item>"; } echo "</channel></rss>"; function escapeXMLVal($xval){ $xval = str_replace('&', '&', $xval); $xval = str_replace('"', '"', $xval); $xval = str_replace('<', '<', $xval); $xval = str_replace('>', '>', $xval); $xval = str_replace("'", ''', $xval); return $xval; } ?>
May 4, 201412 yr Author The problem though with this code is you changed, $title = escapeXMLVal( $dataBlogDisplay['uTitle'] ); $link = escapeXMLVal( $dataBlogDisplay['uID'] ); $description = escapeXMLVal( $dataBlogDisplay['uEntry'] ); $date = escapeXMLVal( $dataBlogDisplay['uAdded'] ); If you don't have them as UTitle, uID, uEntry, and uAdded, then it won't follow the database. I can't change the database because that follows another script and everything would stop working then. So, I changed the dataBlogDisplay to those above, but otherwise kept the code you gave me. I now have this error, This page contains the following errors:error on line 15 at column 46: Document is empty Below is a rendering of the page up to the first error. Edited May 4, 201412 yr by Lovelessly
May 4, 201412 yr If your query is correct: $query = "SELECT title , description, url, created_date FROM ".table_rss." WHERE status=1 ORDER BY created_date desc"; then you need to map columns named: title , description, url, created_date to RSS Fields uTitle, uID, uEntry, uAdded do not exist.
May 5, 201412 yr Author If your query is correct: $query = "SELECT title , description, url, created_date FROM ".table_rss." WHERE status=1 ORDER BY created_date desc"; then you need to map columns named: title , description, url, created_date to RSS Fields uTitle, uID, uEntry, uAdded do not exist. I don't understand. uTitle, etc is how the updates are set up in the database. So how is the script going to know what to take from the database if these (uTitle, etc) aren't somewhere in the RSS?
May 5, 201412 yr Author Can you please post "table_rss" structure here? There is no "table_rss". Like I said, I'm using a database from another script that posts the updates. The script doesn't have RSS, so that's what I'm doing. So there is no "table_rss". Here is the updates SQL file though: http://pastebin.com/RRDZApiJ So you can kind of see what I mean. I can't change ANYTHING in this database or it's set up otherwise the script will stop working. So I have to make the RSS work around the database set up.
May 5, 201412 yr <?php define ("DB_HOST", "localhost"); // set database host define ("DB_USER", "alove_listadmin"); // set database user define ("DB_PASS", "xxxxxxx"); // set database password define ("DB_NAME", "alove_listadmin"); // set database name $link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection."); $db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database"); $query = "SELECT uTitle , uID, uEntry, uAdded FROM wyngs_updates ORDER BY uAdded desc"; $getBlogDisplay = mysql_query($query); header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8" ?>'. '<rss version="2.0"> <channel> <title>A Love Letter</title> <link>http://aloveletter.co.uk/</link> <description>a fanlisting collective</description> <language>en-us</language>'; while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){ $title = escapeXMLVal( $dataBlogDisplay['uTitle'] ); $link = escapeXMLVal( $dataBlogDisplay['uID'] ); $description = escapeXMLVal( $dataBlogDisplay['uEntry'] ); $date = escapeXMLVal( $dataBlogDisplay['uAdded'] ); echo "<item> <title>$title</title> <pubDate>$date</pubDate> <link>$link</link> <description>$description</description> </item>"; } echo "</channel></rss>"; function escapeXMLVal($xval){ $xval = str_replace('&', '&', $xval); $xval = str_replace('"', '"', $xval); $xval = str_replace('<', '<', $xval); $xval = str_replace('>', '>', $xval); $xval = str_replace("'", ''', $xval); return $xval; } ?>
May 5, 201412 yr Author Same error, This page contains the following errors:error on line 15 at column 46: Document is empty Below is a rendering of the page up to the first error.
May 5, 201412 yr I'm lost, try to replace line 15 with echo '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'.
May 5, 201412 yr Author I'm lost, try to replace line 15 with echo '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'. Done! Now this error, This page contains the following errors:error on line 49 at column 3: Extra content at the end of the document Below is a rendering of the page up to the first error. Sorry, I know it's a pain. I REALLY appreciate your help though!!
Create an account or sign in to comment