Jump to content

Recommended Posts

I'm just starting to learn php and am trying to add a paramter $full_key_word into the string below. I'm wanting $full_key_word to replace "keyword" in the string. I've tried lots of things and I'm stumped. Any ideas?

 

$rssFeeds = array(

0 => 'http://blogsearch.google.com/blogsearch_feeds?hl=en&q=keyword&ie=utf-8&num=10&output=rss',

);

Link to comment
https://forums.phpfreaks.com/topic/170483-insert-a-parameter-into-a-string/
Share on other sites

It doesn't throw back errors like some of the stuff I've tried, but it still doesn't work. Is it possible that this new script is pulling a feed with $full_key_word in the url instead of processing that parameter and inserting whatever it produces?

 

 

 

Why not just replace the whole thing..

$keyword = foo;
$rssFeeds[0] = 'http://blogsearch.google.com/blogsearch_feeds?hl=en&q='.urencode($keyword).'&ie=utf-8&num=10&output=rss';

If the $rssFeeds variable does not require any extreme changes, place that after or in place of your old code.. and it'll change the keyword to what you set it as. $keyword could be set through $_GET if you wanted etc.

The script is just a feed parser. It pulls data from an rss feed, but I'm trying to make it pull a different feed based on whatever words are made with $full_key_word. When I try running the new code you made, it just pulls back an empty feed which either means it's not working, or it's pulling back a feed for $full_key_word which there are no feed items for.

 

Is it possibly pulling this:

http://blogsearch.google.com/blogsearch_feeds?hl=en&as_drrb=q&as_qdr=d&q=$full_key_word&ie=utf-8&num=10&output=rss

 

 

My code works fine, I tested it myself! Go to these urls..

$keyword = WHATEVER
$rssFeeds[0] = 'http://blogsearch.google.com/blogsearch_feeds?hl=en&q='.urencode($keyword).'&ie=utf-8&num=10&output=rss';

http://blogsearch.google.com/blogsearch_feeds?hl=en&q=dog&ie=utf-8&num=10&output=rss

http://blogsearch.google.com/blogsearch_feeds?hl=en&q=foo&ie=utf-8&num=10&output=rss

http://blogsearch.google.com/blogsearch_feeds?hl=en&q=wow&ie=utf-8&num=10&output=rss

 

They all work as rss, your parsing is done wrong then? What queries ARE returning something?

I think I've figured out a few more php tidbits this weekend trying to get this to work. It turns out they all worked, and I'm now using the code by asmith.

 

I'm not sure how to explain why it didn't work at first, but it had something to do with not liking any parameters I was using in it. It worked perfectly when I used non-parameter words in the script, but eventually got it working by using a different parameter.

 

Much thanks!

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.