1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Noob PHP question of the year

Discussion in 'PHP & Perl' started by Frankie4Fingers, Mar 26, 2010.

  1. Frankie4Fingers

    Frankie4Fingers Power Member

    Joined:
    Jan 8, 2009
    Messages:
    676
    Likes Received:
    214
    I'm trying to add a line of code to a WP search results page so to call feeds related to the search keyword. I'm using WP 2.9.2 with Simple Pie Core and Simple Pie for WP.

    The line I added is this:

    Code:
    <?php echo SimplePieWP('http://www.site.com/jc/rss_lastinsert.jsp?k=teacher&country=UK&l=<? echo $_GET["s"] ?>'); ?>
    The WP search result page loads but gives the following error: XML error: Invalid document end at line 1, column 1

    I'm 100% sure the error in the line of code is

    Code:
    <? echo $_GET["s"] ?>
    because if I put the name of a location (e.g. London) in its place all works fine and the search page results show feeds related to job offers for teacher in London.

    How can I solve this?

    Thanks in advance.
     
  2. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    Well I can tell you right off the bat that you dont need the <? and ?> around $_GET["s"]. You don't need to echo it again either.

    Try something like this:
    PHP:
    <?php echo SimplePieWP('http://www.site.com/jc/rss_lastinsert.jsp?k=teacher&country=UK&l=' $_GET["s"]); ?>
     
    • Thanks Thanks x 1
  3. adbox

    adbox Power Member

    Joined:
    May 1, 2009
    Messages:
    658
    Likes Received:
    107
    Home Page:
    how did that go?
     
    • Thanks Thanks x 1
  4. Frankie4Fingers

    Frankie4Fingers Power Member

    Joined:
    Jan 8, 2009
    Messages:
    676
    Likes Received:
    214
    Worked like a charm!

    Thanks to both :)