NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Remove variable from $_SERVER['QUERY_STRING']

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 01-29-2006, 12:14 PM THREAD STARTER               #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Remove variable from $_SERVER['QUERY_STRING']


I need to remove the variable $m from my querystring... the querystring is variable, and $m is never always in the same place, and never the same variable.

I want to make a link from search.php?m=blah&q=blah2 etc... to search.php?m=something_else_now&q=blah2 < same again. Now, there could potentially be hundreds of variables in my querystring, and $m could be anywhere in there, so I can't just take the first x letters off. Also the value of $m varys in length depending on the the user's preferences.

Is there any way I can take the $m value out of the querystring?

Thanks
Tom

Hey, I put my mind to it, and I got it!

if anyone wants the code: here it is:

PHP Code:
$querystring explode("&",$_SERVER['QUERY_STRING']);
                
$qs_nos 0;
                
                
$qs_final "?";
                while(isset(
$querystring[$qs_nos])){
                  if(!
ereg("m=",$querystring[$qs_nos])){ // change the "m=" to "var_to remove="
????: NamePros.com http://www.namepros.com/programming/162635-remove-variable-from-_server-query_string.html
                    
$qs_final .= $querystring[$qs_nos]."&";
                  }
                  
$qs_nos++;
????: NamePros.com http://www.namepros.com/showthread.php?t=162635
                } 
$qs_final is the variable that holds the new querystring with your var removed!
PoorDoggie is offline  
Old 02-02-2006, 08:16 AM   #2 (permalink)
Senior Member
 
netzilla's Avatar
Join Date: Aug 2005
Posts: 1,717
netzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to behold
 



That was on the lines of what i was thinking also. Thanks for sharing.
netzilla is offline  
Old 02-02-2006, 11:13 AM   #3 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
alternatively you could do the following:-

PHP Code:
$name_of_varialbe 'b';
????: NamePros.com http://www.namepros.com/showthread.php?t=162635
unset(
$_GET[$name_of_varialbe]);
$string '?';
$counted count($_GET);
$count 0;
foreach (
$_GET as $key=>$value)
{
    
$string .=$key.'='.$value;
    
$count++;
    if (
$count!=$counted)
    {
        
$string .= '&';
    }

$name_of_varialbe is the variable which will hold the name of the variable you wish to be removed. $string is the result string after it has been removed.
Peter is offline  
Old 02-06-2006, 12:24 PM THREAD STARTER               #4 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



that maybe better for me, as it won't accidentally cut a string in half if the user uses a "m=" in the middle of a string (as if... lol - better safe than sorry)
PoorDoggie is offline  
Closed Thread


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript problem: undefined variable Shad Programming 3 08-20-2005 05:44 AM
read ms access database, store value in javascript variable Niko2005 Programming 0 05-15-2005 09:37 PM
Remove REGISTRAR-LOCK? marcuss Domain Name Discussion 6 11-12-2004 10:58 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:29 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger