I Will Pay $10 To The First Person Who Can Help Me With This Script (Very Easy Fix)

Discussion in 'Programming' started by Fat_Man, Jun 10, 2011.

  1. #1
    Hello I have an RSS script and everytime it gets parsed and there is a character in there such as < or " I keep getting errors and its showing up as the html version instead of Ansii here is the sample of the error:

    This page contains the following errors:

    error on line 10 at column 121: Extra content at the end of the document
    Below is a rendering of the page up to the first error.


    <title>Êàê âçëîìàòü ïàðîëü íà îäíîêëàññíèêàõ Coupon Codes - Êàê âçëîìàòü ïàðîëü íà îäíîêëàññíèêàõ Offer Codes and Discounts</title>

    <pubDate> 2011-06-10 20:51:14</pubDate>



    <description>women dating younger men, &amp;lt;a href=&amp;quot;http://gasulfupe.e.gp/jys_ramu.html&amp;quot;&amp;gt;öåíòð îáóâü&amp;lt;/a&amp;gt;, 724, &amp;lt;a href=&amp;quot;http://absacseis...</description>

    <link>http://coupo.org/http://keymetosep.info.cm/sep_lox.html/ </link>


    as you can see the title is garbled and this is also the same listing that I am getting the above error on.

    All I would like to do is replace characters in this feed with characters that I want them to be replaced with.

    The first person who gives me the answer will be paid. Please do not fight with me fellas I am only awarding one person and thats only if his idea works...

    Also anyone looking for freelance, I am looking for freelance PHP workers. If you apply I will provide you with a simple task and if you can perform it in a timely fashion I will have plenty of work to keep your workload full.
     
    Fat_Man, Jun 10, 2011 IP
  2. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    This is confusing and without seeing the RSS script my solution for replacing your characters would be adding the following line:

    
    $bad_character = '<';
    $good_character = '&#60;'
    $rss_feed = file_get_contents('http://feeds.feedburner.com/coupo/');
    $rss_feed_clean = str_replace($bad_character, $good_character, $rss_feed);
    echo $rss_feed_clean;
    
    PHP:
    You can set up an array of good and bad characters to look for and then instead of simply echoing the clean file, have it write it (or publish it with Feedburner).
     
    Alastair Gilfillan, Jun 10, 2011 IP
  3. The Webby

    The Webby Peon

    Messages:
    1,852
    Likes Received:
    30
    Best Answers:
    1
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Can you post the snippet of the code containing line 10, or PM me so I can take a look?
     
    The Webby, Jun 11, 2011 IP
  4. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    i think this is what you need.. hope it helps coz i spent some time typing it :p

    
    <?
    
    //declare an array of characters you want to replace
    
    $findme[0] = '&amp;lt;';
    $findme[1] = '&amp;quot;';
    $findme[2] = '&amp;gt;';
    
    //remember the no. of characters/strings you are replacing.. in this case it is 3
    
    $count = 3;
    
    //or you can also use following : Just uncomment it to use it.
    //$count = count($findme);
    
    
    //declare similar replace character/string array corresponding to $findme array
    
    $replacewith[0] = '<';
    $replacewith[1] = '"'; //double quote inside single quotes
    $replacewith[2] = '>';
    
    
    //now replace these characters in the feed
    
    $myfeed = file_get_contents('http://feeds.feedburner.com/coupo/');
    
    for($i=0;$i<$count;$i++)
    {
    	$myfeed = str_replace($findme[$i],$replacewith[$i],$myfeed);
    }
    
    echo $myfeed; //this feed is as u want it to be
    
    ?>
    
    PHP:
    Edit :

    You asked for replacing thing so i gave you this method!
    but if you just have problem with &amp;lt; etc.. then i guess you can use the default php function html_entity_decode ()

    for e.g.

    
    
    $myfeed = file_get_contents('http://feeds.feedburner.com/coupo/');
    
    $myfeed = html_entity_decode ($myfeed);
    
    echo $myfeed;
    
    
    PHP:
     
    Last edited: Jun 11, 2011
    niks00789, Jun 11, 2011 IP
  5. The Webby

    The Webby Peon

    Messages:
    1,852
    Likes Received:
    30
    Best Answers:
    1
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    No error in this code. It runs fine, at least on my server.

    But are you sure you have right strings in $findme array. because html code for <, " and > are &lt;, &quote; and &gt. Not &amp;lt;, &amp;quote; and &amp;gt;
     
    The Webby, Jun 11, 2011 IP
  6. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    ya i know that, but i have coded it as per what i thought was topic opener's need

    He said it gives the output in such a way

    so merely by seeing the code i can guess that his script is converting '<' ==> '&lt;' ==> '&amp;lt;' and similarly for other special characters

    so i suggested the above code... :)
     
    niks00789, Jun 11, 2011 IP
  7. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    Now Fat_Man has some options for free! ;)
     
    Alastair Gilfillan, Jun 12, 2011 IP
  8. Fat_Man

    Fat_Man Peon

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    sorry guys I didnt respond sooner. I found the problem. Someone was adding spam to my RSS and that was the problem. I now made it so that I have to approve the content before adding... dumb noob mistake.
     
    Fat_Man, Jun 18, 2011 IP
  9. Alastair Gilfillan

    Alastair Gilfillan Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    Haha whoops! ;)
     
    Alastair Gilfillan, Jun 19, 2011 IP