Jump to content

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.