SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    QuerryString passes to link as directory

    Hi everyone.

    I searched the forum for this and it is likely out there if I knew the right terms to search for.

    I want to pass the value of the querrystring "foo" on to a link as a directory.

    www.mysite.com?foo

    the link to other_site.com becomes

    www.other_site.com/foo


    This doesn't quite work.
    Parse error: syntax error, unexpected ')', expecting T_VARIABLE or '$' in link.php on line 4



    PHP Code:
    <?php

    echo '<a href="http://www.other_site.com/'urlencode($), '">Next page</a>';

    ?>

    Thanks in advance

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ah, seems you're a new guy to php.

    you have to name the variable, not just put a $.

    therefore, your code will be (simplified and to PHP standards as i know them)
    PHP Code:
    <?
    $nextpage 
    urlencode($_GET['foo']);
    echo 
    "<a href=\"http://www.other_site.com/$nextpage\">next page</a>";
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •