passing an ampersand in url?

Discussion in 'PHP' started by mahmood, Apr 9, 2006.

  1. #1
    I wonder how I can put a value with ampersand in a url like this:

    myPage.php?names=rodney & harry
    PHP:
    .
     
    mahmood, Apr 9, 2006 IP
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand you correctly.... you want to put an ampersand into a URL, but you don't want that ampersand to be interpreted as another parameter to the URL? If so then you can escape it using %26 like this:

    myPage.php?names=rodney%26harry
    Code (markup):
     
    tflight, Apr 9, 2006 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just use the urlencode function on your data before sending it. The output will be what tflight posted, but it's easier for you.
     
    exam, Apr 9, 2006 IP
  4. mahmood

    mahmood Guest

    Messages:
    1,228
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for replies
     
    mahmood, Apr 9, 2006 IP
    exam likes this.
  5. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You're very welcome. :)
     
    exam, Apr 9, 2006 IP