Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Posts
    135
    Thanks
    83
    Thanked 0 Times in 0 Posts

    Small Str_Replace Problem

    I am trying to send a URL to a webpage like the following:
    http://siteone.com/?url=http://google.com

    This I have got working fine but when there are additional variables in the second URL this is when problems occur, E.g.
    http://siteone.com/?url=http://googl...ch=keyword&c=1

    So Instead of doing it like this (I am the original person that sends the URL data in the URL) I have changed it so that I search and replace all &'s with ;'s before it is sent with the following:

    $url = $subfetch['link'];
    $url = str_replace("&",";",$url);
    header ("location:".$url);

    But for some reason it is not replacing the & symbols. I can see in my browser that the next page says:
    http://siteone.com/?url=http://googl...ch=keyword&c=1

    Instead of replacing the &'s with ;'s.

    Can anyone see what I am doing wrong here or know of an alternative way to obtain a URL from a URL like this?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You are going about this the wrong way. I suggest that you use urlencode to encode the url so the url query string goes through fine then whatever site you need to get the url variable from just use urldecode.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Sussex_Chris (01-07-2010)


  •  

    Posting Permissions

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