SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    0 Post(s)
    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.

    the link to becomes

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

    PHP Code:

    echo '<a href="'urlencode($), '">Next page</a>';


    Thanks in advance

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Lancaster University, UK
    2 Post(s)
    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=\"$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


Posting Permissions

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