Undefined index Problem

Hi There,

I am having trouble with an Undefined index error, I don’t understand why it is not working as I have used a similar element before. The error I am getting is Notice: Undefined index: PartID in /home/bkirk4747/public_html/php/partsums.php on line 26

Line 26 is //Get Part_Number
$iPartID = $_GET[“PartID”];

[php]// Before using $_POST[‘value’]
if (isset($_GET[‘PartID’]))
{
// Instructions if $_POST[‘value’] exist
}

//Get Part_Number
$iPartID = $_GET[“PartID”];

ECHO “<img src=“http://www.brickbybricks.ca/php/".$iPartID.".png”>”;

$oorders = mysql_query("

SELECT Parts.PartID, Colors.Color_Name, Parts.Part_Name, Categories.Category_Name, Sum(Orders.Qty) AS SumOfQty
FROM Stores
LEFT JOIN Colors
LEFT JOIN Categories
LEFT JOIN Currencies
LEFT JOIN Parts
LEFT JOIN Orders
ON Parts.PartID = Orders.PartID
ON Currencies.CurrencyID = Orders.CurrencyID
ON Categories.CategoryID = Orders.CategoryID
ON Colors.ColorID = Orders.ColorID
ON Stores.StoreID = Orders.StoreID
GROUP BY Parts.PartID, Colors.Color_Name, Parts.Part_Name, Categories.Category_Name
ORDER BY Colors.Color_Name, Categories.Category_Name;

") or die(mysql_error());

ECHO “

”;
ECHO “”;
ECHO “”;
ECHO “”;
ECHO “”;
ECHO “”;
ECHO “”;
ECHO “”;
ECHO “”;

while($row = mysql_fetch_array($oorders))
{

ECHO “

Part#
Color Name”;
ECHO “
Part Name”;
ECHO “
Category Name”;
ECHO “
Total Ordered”;
ECHO “
”;
ECHO “”;
ECHO “";
ECHO “";
ECHO “";
ECHO “";
ECHO “";
ECHO “”;
ECHO “”;
ECHO “
”.$row[‘PartID’]."”.$row[‘Color_Name’]."”.$row[‘Part_Name’]."”.$row[‘Category_Name’]."”.$row[‘SumOfQty’]."
”;

}
?>

[/php]

The fields exist in a Mysql database, and I have checked to make sure that the fields have information in them. So I am stumped.

I have severe readability issues with your code, but that is a different matter.

Think about this:
[php]
// Before using $_POST[‘value’]
if (isset($_GET[‘PartID’]))

// You are using $_GET, but the comments indicate you are expecting $_POST?

{
// Instructions if $_POST[‘value’] exist
}

//Get Part_Number
$iPartID = $_GET[“PartID”];

//You are assigning the value to a new variable ( which isn’t needed by the way )
//even if the variable dosn’t exists?

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service