want to get & instead & in address line

Discussion in 'PHP' started by aayybb, Jul 29, 2009.

  1. #1
    aayybb, Jul 29, 2009 IP
  2. Leron

    Leron Active Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    53
    #2
    Are you using PHP?
     
    Leron, Jul 29, 2009 IP
  3. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes. I am using PHP. I had tried urlencode($str) and filter_var($str, FILTER_SANITIZE-ENCODED). But it doesn't do what I want.
     
    aayybb, Jul 29, 2009 IP
  4. Leron

    Leron Active Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    53
    #4
    Did you by any chance use the htmlentities() or htmlspecialchars() function on the url. Those two will change "&" to "&"

    Can you show me a sample of your code, I can help you better that way.
     
    Leron, Jul 29, 2009 IP
  5. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I noticed a problem. For the following code, the 1st header change the & to & which is not what I want. But the 2nd header example does what I want and keep the & in the url when I ran it. Do you know why? Thanks for any help in advanced.

    $url = 'http://www.abc.com/sample.php?customer=Jane&phone=1234567';

    header('Location: ' . $url);

    header('Location: http://www.abc.com/sample.php?customer=Jane&phone=1234567');
     
    aayybb, Jul 29, 2009 IP
  6. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I think htmlspecialchars() is the reason for my problem. I found it in the link function. Because this is a huge program and I am trying to simplify my problem here so I don't ask any experts to dig through the huge codes while trying to help me. Sorry for not having all the information here. Thanks for your help and the tip of htmlspecialchars() here.
     
    aayybb, Jul 29, 2009 IP