Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse variable to display in Carp RSS to HTML

Status
Not open for further replies.

smavtron

Technical User
Jul 28, 2007
17
US
I have a RSS feed

Code:
[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777[/URL]

which I can display directly (hard code) in the script by doing

Code:
CarpCacheShow('[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777')[/URL]

and it works OK.

Going a step ahead I want to display this by calling it as variable in a browser

Code:
/test.php?rss=[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777[/URL]

and want to include in the code as

[/code]
CarpCacheShow('.urlencode(stripslashes($_GET['rss'])).')
Code:
I am using this way because urlencode ensures that it will work even if I have spaces or something in the link. stripslashes ensures that I don't have backslashes in front of quote marks. $_GET ensures that the code will work on servers that don't set globals for the query string arguments.

Unfortunately this does not work. If I use a regular rss feed [URL unfurl="true"]www.cnn.com/services/podcasting/newscast/rss.xml[/URL] by calling 

[code]
/test.php?rss=[URL unfurl="true"]www.cnn.com/services/podcasting/newscast/rss.xml[/URL]

it works. So I am making error in

Code:
?loc=273&grp=4&pid=1519777

part of the code. How to capture for feed. the "=" and "&"

If I use <?php echo $rss; ?> it displays the link.

Can anyone suggest how I can solve this.

TIA.
 
How about this :

Code:
$rss = base64_encode("[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777");[/URL]

/test.php?rss=$rss

CarpCacheShow(base64_decode($_GET["rss"]));
 
I am able to understand

Code:
CarpCacheShow(base64_decode($_GET["rss"]));

but not clear on suggestion

Code:
$rss = base64_encode("[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777");[/URL]

/test.php?rss=$rss

the url will be
Code:
/test.php?rss=[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777[/URL]
[code]

can you clarify

[code]
$rss = base64_encode("[URL unfurl="true"]http://www.buy.com/rss/feed.asp?loc=273&grp=4&pid=1519777");[/URL]

/test.php?rss=$rss
 
Thanks for clarifying... but I need clarification on your clarification :) though ur suggestion works

The url in first place is

test.php?rss=
and not

test.php?rss=aHR0cDovL3d3dy5idXkuY29tL3Jzcy9mZWVkLmFzcD9sb2M9MjczJmdycD00JnBpZD0xNTE5Nzc3

may be I am really dumb.

then how r u suggesting

$rss = base64_encode("
Your url becomes :
test.php?rss=aHR0cDovL3d3dy5idXkuY29tL3Jzcy9mZWVkLmFzcD9sb2M9MjczJmdycD00JnBpZD0xNTE5Nzc3
 
Sorry but I don't understand your question :(

Where do you get the url from in the first place?

I don't see what's difficult to encode it before passing it as a GET variable and then decode it for your CarpCacheShow() function.
 
if we assume that you are typing the url into a text box and that the text box is called (for the sake of argument) rssfeed then the php code will simply be

Code:
set_magic_quotes_runtime(0);
CarpCacheShow(clean($_GET["rssfeed"]));

function clean($url){
 if (get_magic_quotes_gpc()){
   $url = stripslashes($url);
 }
 return $url;
}

i.e. all that we are really trying to do is undo the appalling harm of magic_quotes. the browser and php intermediate the rest of the interaction.
 
These are RSS feeds for various merchants. What would be the best method to do?... based on suggestion Sleidia, I was thinking to

1. Create a database with links
2. Pull the encoded links on a page... set the variable with encode base64_encode(link1)...base64_encode(link2)
3. The links will be for ex. test.php?rss=link1
4. Once the link is clicked, it will get displayed with using CarpCacheShow(base64_decode($_GET["rss"]));

jpadie in your suggestion.... based on the details I put above, what you would suggest?
 
store the data in the database in the normal way (as plain text) and use the function i posted.

make sure that the data is written to the database with magic_quotes_runtime switched off and with escaping (mysql_real_escape_string() - for mysql) used on each value.
 
jpadie... I am able to get the script working using Sleidia suggestions. Can you please clarify your suggestion step-by-step. Don't know that mucg prgramming.

Also... need help displaying data. I have 4 variables, namely Merchant, sub_cat, link_detail & link and want to display on the page as

Merchant

sub_cat

<a href=link>link_detail</a> <a href=link>link_detail</a>
<a href=link>link_detail</a> <a href=link>link_detail</a>

sub_cat
<a href=link>link_detail</a> <a href=link>link_detail</a>
<a href=link>link_detail</a> <a href=link>link_detail</a>

The same merchant can have different sub_cat as Computers, Electronics etc.

I want exactly the page to show as an example on Buy.com ...

TIA.
 
my suggestion was set out step by step.
the code i posted simply says that if magic quotes have been applied, remove them.
if sleidia's solution works for you then great. you have your answer (although I must have misunderstood your question).
if you have another query then you should post another thread.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top