> Date: Thu, 25 Feb 2010 13:03:57 -0600
> From: nos...@mckenzies.net
> CC: aj...@alumni.iu.edu; php-general@lists.php.net
> Subject: Re: PHP "GET" Error?
> 
> Shawn McKenzie wrote:
> > Alice Wei wrote:
> >> Hi, 
> >>
> >>     I have done something wrong here, because when I have my variables 
> >> declared in my PHP:
> >>
> >>    $people_from = $_GET['people_from'];
> >>    $state_colors= $_GET['state_colors'];
> >>
> >>   I get this url: http://localhost/generic.php?people_from=Adair, 
> >> OK-Alfalfa, OK-Atoka, OK-Beaver, OK-Beckham, OK-Blaine, OK-Bryan, 
> >> OK-Caddo, OK-Canadian, OK-Carter, OK-Cherokee, OK-Choctaw, OK-Cimarron, 
> >> OK-Cleveland, OK-Coal, 
> >> OK&state_colors=#FFFFCC-#FFFFCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC
> >>
> >>  The result? I don't get any colors on the screen as I have here in the 
> >> url. 
> >> However, if I do:
> >>    
> >> $people_from = "Adair, OK-Alfalfa, OK-Atoka, OK-Beaver, OK-Beckham, 
> >> OK-Blaine, OK-Bryan, OK-Caddo, OK-Canadian, OK-Carter, OK-Cherokee, 
> >> OK-Choctaw, OK-Cimarron, OK-Cleveland, OK-Coal, OK";
> >> $state_colors= 
> >> "#FFFFCC-#FFFFCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC-#FFCCCC";
> >>
> >> I get the correct result. In total, there are 77 entries (I only put 15 
> >> here). Is there a length limit for what I pass to the url? If not, how 
> >> come there are no colors showing up in my image as I desired according to 
> >> my url?
> >>
> >> Thanks for your help.
> >>
> >> Alice
> >>                                      
> >> _________________________________________________________________
> >> Hotmail: Free, trusted and rich email service.
> >> http://clk.atdmt.com/GBL/go/201469228/direct/01/
> > 
> > There are characters in the URL that have a meaning within a URL itself
> > (such as #).  Use urlencode() before putting the data in the URL.
> > 
> 
> FWIW, how I would probably handle this is to have an array of
> $people_from and an array of $state_colors and then serialize() them and
> run through urlencode().  Then you have an array on the next page.  Much
> easier to work with:
> 
> $people_from = array('K-Alfalfa', 'OK-Atoka'); //etc...
> $state_colors = array('#FFFFCC', '#FFFFCC'); //etc...
> 
> Then the link would be:
> 
> $url =
> 'generic.php?people_from='.urlencode(serialize($people_from)).'&state_colors'.urlencode(serialize($state_colors));
> 
> You then have a $_GET['people_from'] and $_GET['state_colors'] array on
> the next page.

  On another note, would this be different if I used POST instead of GET? 
(considering there are some limitation on the length of my url) I tried to look 
into that, but I don't see anything. 

Alice

> -- 
> Thanks!
> -Shawn
> http://www.spidean.com
                                          
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/

Reply via email to