need a little help... probably easy but just not seeing it!!!

Discussion in 'PHP' started by cgo85, Mar 27, 2008.

  1. #1
    I am trying to GET the 'city' from the URL and I can't figure how to pass the 'city' variable into the url string correctly. It's not recognizing the 'city' variable

    <?php
    /*
    ======================================================================
    lastRSS usage DEMO 2
    ----------------------------------------------------------------------
    This example shows, how to
    - create lastRSS object
    - set transparent cache
    - get RSS file from URL
    - access and show fields of the result
    ======================================================================
    */
    $city = $_GET['city'];
    // include lastRSS

    include "./lastRSS.php";


    // Create lastRSS object
    $rss = new lastRSS;

    // Set cache dir and cache time limit (1200 seconds)
    // (don't forget to chmod cahce dir to 777 to allow writing)
    $rss->cache_dir = './temp';
    $rss->cache_time = 1200;

    // Try to load and parse RSS file
    if ($rs = $rss->get('http://news.google.com/news?q=real+estate+$city&output=rss')) {
    // Show website logo (if presented)
    // if ($rs[image_url] != '') {
    //echo "<a href=\"$rs[image_link]\"><img src=\"$rs[image_url]\" alt=\"$rs[image_title]\" vspace=\"1\" border=\"0\" /></a><br />\n";
    // }
    // Show clickable website title
    // echo "<span class=\"gensmall\"><big><b><a href=\"$rs[link]\" rel=\"nofollow\">$rs[title]</a></b></big></span><br />\n";
    // Show website description
    //echo "<span class=\"gensmall\">$rs[description]</span><br />\n";
    // Show last published articles (title, link, description)
    // echo "<ul>\n";
    echo "$city Real Estate News - <a href=\"http://news.google.com\" rel=\"nofollow\"><i>provided by Google News</i> :</a><br><br>";
    foreach($rs['items'] as $item) {
    echo "<span class=\"gensmall\"><a href=\"$item[link]\" rel=\"nofollow\">".$item['title']."</a><br />".$item['description']."</span>\n<br><br>";
    }
    echo "\n\n";
    }
    else {
    echo "RSS Feed is currently unavailable\n";
    }
    ?>
     
    cgo85, Mar 27, 2008 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if ($rs = $rss->get('http://news.google.com/news?q=real+estate+' . $city . '&output=rss')) { 
    PHP:
     
    decepti0n, Mar 27, 2008 IP
  3. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks alot! I knew it was something simple i was just not seeing!
     
    cgo85, Mar 27, 2008 IP