$_GET Not working as expected: Undefined index: image_id
Posted: Mon Nov 17, 2008 11:58 pm
I have read several docs concerning $_Get. My understanding is that it is a global. But I get a notice message: Notice: Undefined index: image_id in C:\AppServ\www\MM_Main.php on line 94 when using it. Though my images appear just fine. Why am I getting the messages and how do I get rid of them?
My code with the image_id's (index.php)
My the end of my code in my main php program, main.php, (which calls other functions to open files reading data, do calculations, creates my four images.)
Shouldn't the print statement show me the image id and shouldn't it appear four times? I only appears once! I get four images...Also, if I remove the "require main.php" line, I do not get the message and my images appear fine. But if I try to also output text from anywhere, the images become blank boxes.
Any assistance or insight would be greatly appreaciated! Thank you
My code with the image_id's (index.php)
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My PHP Catastrophe</title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require("MM_Main.php");
show_calcs($SlowAry,"Slow Array", $Symbol, $SlowMaxBar);
?>
<p>
<img src="MM_Main.php?image_id=1" border="0">
<img src="MM_Main.php?image_id=2" border="0">
<img src="MM_Main.php?image_id=3" border="0">
<img src="MM_Main.php?image_id=4" border="0">
</p>
</body>
</html>Code: Select all
//determine which data from the array to use
get_context($FastBar, $SlowAry, $MedmAry, $FastAry, $SlowMaxBar, $MedmMaxBar, $FastMaxBar,
$SymbLTF, $SymbTbl, $MedmParentBar, $SlowParentBar);
//create the image using the data, returns an image resource
$CrwdMvImg4 = display_CrwdMv($SlowAry, $MedmAry, $FastAry, $SlowParentBar, $MedmParentBar, $FastBar);
//display my four images
header("Content-Type: image/png");
print "Image ID={$_GET["image_id"]}<br/>"; //this line appears 1 time and with no value
if ($_GET["image_id"] == 1) imagepng($CrwdMvImg1);
else if ($_GET["image_id"] == 2) imagepng($CrwdMvImg2);
else if ($_GET["image_id"] == 3) imagepng($CrwdMvImg3);
else if ($_GET["image_id"] == 4) imagepng($CrwdMvImg4);
?>Any assistance or insight would be greatly appreaciated! Thank you