RE: PHP "GET" Error?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, 

  I forgot to mention that the url is formed from Actionscript, I am just using PHP to do the "I/O" because Actionscript does not have this option. 

  So, I guess I cannot do the serialize here like you suggested. I have changed # to 0x for now, and that does not seem to help yet. 
  BTW, below is the complete code, would this help with my choices?

<?php

header("Content-type: image/svg+xml"); //Outputting an SVG 

$from = $_GET['from'];
$state_colors= $_GET['state_colors'];

$from = explode("-", $from);
$state_colors= explode("-", $state_colors);

#Load the Map
$ourFileName= "USA_Counties_with_FIPS_and_names.svg";
$fh = fopen($ourFileName, "r") or die("Can't open file");
$contents = fread($fh,filesize($ourFileName));
$lines2= file($ourFileName);

foreach ($lines2 as $line_num => $line2) { 

$style_line_num = $line_num+3;
$line2 = trim($line2);

      if(preg_match("/^style/",$line2)) {

       $rest = substr($line2,0,-1);          

       for ($j=$line_num;$j<=$style_line_num;$j++){
         if(preg_match("/inkscape:label/",$lines2[$j])) {  
            $location = explode("=",$lines2[$j]);
            $location2 = substr($location[1],1,-6);  
           
            if(in_array($patient_location2, $patient_from)) {
           
             $key= array_search($location2,$from); //Find out the position of the index in the array
             $colors_style = ";fill:" . $state_colors[$key];  //Use the index from array_search to apply to the color index
             $rest2 = substr($line2,0,-1). $colors_style . "\"";            
             echo $rest2 . "\n";
            }
            else echo $line2 . "\n";             

         } //end preg_match inkscape        
     } //end for loop
   }  //If preg_match style

     else echo $line2 . "\n"; //else if preg_match style     
 } //end for each    

fclose($fh);
?>

Thanks for your help. 

Alice

> Date: Thu, 25 Feb 2010 13:03:57 -0600
> From: nospam@xxxxxxxxxxxxx
> CC: ajwei@xxxxxxxxxxxxx; php-general@xxxxxxxxxxxxx
> 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.
> 
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com
 		 	   		  
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux