Current location: Hot Scripts Forums » Programming Languages » PHP » Trouble with parameter passing in URLs and str_replace


Trouble with parameter passing in URLs and str_replace

Reply
  #1 (permalink)  
Old 09-14-03, 11:27 AM
crookyboy crookyboy is offline
CJ-Design.com Webmaster
 
Join Date: Aug 2003
Location: Derby, UK
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Trouble with parameter passing in URLs and str_replace

Hi everyone,

First of all:

I am using the following code:

// example: "site" = http://www.google.com ....

$site = strtolower($_GET['site']);
$delete = array("http://", "ftp://","www.");
$show = str_replace($delete, "", $site);

// $show will hold the value "google.com"

this works! What doesn't work is if I put "site" as "http://www.google.com/adsense/root/images/whatever" it gives "http://www.google.com/adsense/root/images/whatever"

What is going wrong?


Secondly:

I also have another problem which I havent a clue how to fix.
When a "URL" is passed to my script in this way:

scriptname.php?site=http://www.google.com

it works fine, but if the URL has variables in it like:

?site=http://www.google.com/?q=Webmaster+World&LANG=UK

it chops of the &LANG part because it is concidered as another variable. How can I take only the variable "url" as a complete string (i.e the whole site URL) from start to finish?


Help is highly appreciated
__________________
James Crooke<br>
<a title="UK Website Design and Programming at affordable prices" href="http://www.cj-design.com">CJ Website Design
Freelance Programmers Register Here!
Reply With Quote
  #2 (permalink)  
Old 09-15-03, 08:25 PM
Chris Boulton Chris Boulton is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
For the second one:

Use the urlencode and urldecode functions of php..

http://www.php.net/urlencode

http://www.php.net/urldecode

This will create your variables friendly to be parsed along the browser and urls...

I'll get back to you on the first one
__________________
Chris Boulton
SurfiOnline!
MyBulletinBoard
Reply With Quote
  #3 (permalink)  
Old 09-16-03, 05:30 AM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
I just tried it and it removes the http:// fine. What version of php are you using?
__________________
PHP / mySQL Developer
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.