0

I'm having trouble passing arguments from html into a php script that I'm using to generate a simple line graph. I'm attempting to use the $_GET method to retrieve the variables.

Here's my html code;

<td><img src="include/drawLinearChart.php?slope='.$xver.'&yInt='.$yver.'&chartName='.$scaleName.'" width="350" height="300" /></td>

And the piece of code in drawLinearChart.php that applies the incoming variables to local variables. I know I don't need to do that and can just use them wherever, but from a troubleshooting perspective I've just been trying to ensure that they get there.

$varSlope = $_GET["slope"];
$varY_Intercept = $_GET["yInt"];
$varScaleName = &_GET["chartName"];

Any help would be appreciated. Thanks.

Rikesh
  • 26,156
  • 14
  • 79
  • 87
iYeager
  • 47
  • 2
  • 7
  • typo: `$varScaleName = &_GET["chartName"];` ? – Tim Withers Jun 10 '13 at 05:05
  • What is the problem you are having? It looks like it is fine... are you getting an error or something? – Tim Withers Jun 10 '13 at 05:06
  • @Tim Withers, that sorta worked, although now it's just passing in the names of the variables, not the values. For example, my $varScaleName is displaying as '.$scaleName.' – iYeager Jun 10 '13 at 05:24
  • @shin, I don't understand your comment. The drawLinearChart.php script outputs a .png file which is located in the html by the img tag. I don't see anywhere that I'd put a link, can you be more specific? – iYeager Jun 10 '13 at 05:54

1 Answers1

0

All,

I found the solution. The html side of things needs to look like this;

<td><img src='include/drawLinearChart.php
        ?slope=<?php echo urlencode($xver); ?>
        &yInt=<?php echo urlencode($yver); ?>
        &chartName=<?php echo urlencode($scaleName); ?>'
        width="350" height="300"/>
</td>

This properly encapsulates everything on the html side and packages it into URI-safe encoding. The output from my Apache log is now this;

"GET /projects/WebUI/include/drawLinearChart.php?slope=1&yInt=3&chartName=0-50PSIG HTTP/1.1" 200 14037

Thanks guys for the above syntax corrections.

-Ian

iYeager
  • 47
  • 2
  • 7