Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-06-2010, 08:02 PM   PM User | #1
Sussex_Chris
Regular Coder

 
Join Date: Apr 2009
Posts: 135
Thanks: 83
Thanked 0 Times in 0 Posts
Sussex_Chris is an unknown quantity at this point
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?
Sussex_Chris is offline   Reply With Quote
Old 01-06-2010, 08:09 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Users who have thanked _Aerospace_Eng_ for this post:
Sussex_Chris (01-06-2010)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:43 PM.


Advertisement
Log in to turn off these ads.