Trying to pass ampersand through query strings in URL

Reply

Join Date: Nov 2008
Posts: 77
Reputation: whitestream6 is an unknown quantity at this point 
Solved Threads: 0
whitestream6 whitestream6 is offline Offline
Junior Poster in Training

Trying to pass ampersand through query strings in URL

 
0
  #1
Jul 24th, 2009
Thank you for the tutorial last time on query strings
It worked for me, this is my working query string:
  1. <?
  2. $i=$_GET['vehicle'];
  3. switch ($i) {
  4. case Chrysler:
  5. include("chryslernew.php");
  6. break;
  7. case Chevrolet:
  8. include("chevnew.php");
  9. break;
  10. default:
  11. echo "include ("nopage.php")";
  12. }
  13. ?>

However, I'm trying to get my PHP URLs with query strings that have multiple pages to look like this:
  1. http://library.digiguide.com/lib/programmenextshowing/238308&hPage=3

I can get the question mark in query string URLs with no problem, but the ampersand has proven difficult for me to get right.
How would I be able to do this in PHP?
Last edited by peter_budo; Jul 24th, 2009 at 3:40 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 883
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 144
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Trying to pass ampersand through query strings in URL

 
0
  #2
Jul 24th, 2009
& is the parameter separator, if you want to pass it as part of the string, use %26 instead.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Trying to pass ampersand through query strings in URL

 
0
  #3
Jul 24th, 2009
yes pritaeas is right
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 77
Reputation: whitestream6 is an unknown quantity at this point 
Solved Threads: 0
whitestream6 whitestream6 is offline Offline
Junior Poster in Training

Re: Trying to pass ampersand through query strings in URL

 
0
  #4
Jul 24th, 2009
Thanks for that. Do I have to create a separate .htaccess or php file to get this to work?

I have http://www.mychevycars.com (virtual host)
and I want to split the pages (page1.php, page2.php) into:
  1. http://www.mychevycars.com/aveo/3door&hPage=1
  2. http://www.mychevycars.com/aveo/3door&hPage=2
  3. http://www.mychevycars.com/aveo/3door&hPage=3

It isn't quite working.
Last edited by whitestream6; Jul 24th, 2009 at 11:36 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 77
Reputation: whitestream6 is an unknown quantity at this point 
Solved Threads: 0
whitestream6 whitestream6 is offline Offline
Junior Poster in Training

Re: Trying to pass ampersand through query strings in URL

 
0
  #5
Jul 24th, 2009
I'm still trying to figure this out... anyone got any advice?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 43
Reputation: dasatti is an unknown quantity at this point 
Solved Threads: 3
dasatti dasatti is offline Offline
Light Poster

Re: Trying to pass ampersand through query strings in URL

 
0
  #6
Jul 24th, 2009
The query string starts after the "?" sign. The first variable must follow the "?" sign which indicates the end of the url path and start of query string variables. Further variables are then seperated by "&" sign. So to access hPage value fro the url it must be like this

http://www.mychevycars.com/aveo/3door?hPage=1 instead of http://www.mychevycars.com/aveo/3door&hPage=1
maSteR of aLL, jAck oF NoNe
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 77
Reputation: whitestream6 is an unknown quantity at this point 
Solved Threads: 0
whitestream6 whitestream6 is offline Offline
Junior Poster in Training

Re: Trying to pass ampersand through query strings in URL

 
0
  #7
Aug 1st, 2009
What would I have to do to my query string?:
  1. <?
  2. $i=$_GET['carname'];
  3. switch ($i) {
  4. case 1:
  5. include("1.php");
  6. break;
  7. case 2:
  8. include("2.php");
  9. break;
  10. default:
  11. echo "page not found!!!!";
  12. }
  13. ?>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 645 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC