Jump to content

PHP link in my rss feed help


brent123456

Recommended Posts

I am having some trouble with my script I am direct linking from my feed.

$output .= "<link>http://localhost/mrlumber/site_pages/index.php?do=viewtheproduct&pid=$row[product_id]</link>\n";
    $output .= "<guid isPermaLink=\"false\">" . $row['product_id'] . "</guid>";

 

It is breaking on the ampersand and will not print out the feed. If I just use the root url it works fine. Anyone know a way I can fix this?

Thanks,

Brent

Link to comment
https://forums.phpfreaks.com/topic/59506-php-link-in-my-rss-feed-help/
Share on other sites

The other thing you might want to look at is the <![CDATA[ ]]>  for XML (or rss feeds) that will ignore special characters and display them as is.

 

It took me forever to figure it out but various characters can break the validation of XML and using the above worked for me.

 

Example:

<?php

$feed = "<item>\n
    <title>{$blog['title']}</title>\n
    <description><![CDATA[{$description}]]?</description>\n
    <link>http://www.tyleringram.com/blog/{$url}</link>\n
    <pubDate>{$pubDate}</pubDate>\n
    <guid>http://www.tyleringram.com/blog/{$url}</guid>\n
    </item>\n\n";

?>

 

Now because $description is my blog's content it has various special characters that would invalidate or break the XML. :) Hope this helps a bit too.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.