Sometimes I just feel too stupid to live. Besides the other issues I identified in the last post I was not specifying the field in my mysql_result()
On the positive side this is my first real function so I guess I had to earn it through blood, sweat and tears. My head hurts.
YAOMK thanks for your assistance in helping me work through my idiocy. At least I learned some error handling.
Here is the final code for anyone that cares:
function prodLookup($Part, $startDate, $endDate) {
$Part = mysql_real_escape_string($Part);
if (!($link = @ mysql_connect("localhost", "guest", "pass")))
die("Cannot connect");
if (!(mysql_select_db("production", $link)))
die("select db failed");
$ProdQty = "SELECT SUM(quantprod) AS Qty
FROM Production
WHERE PartNo = '$Part'
AND Production.ProdDate >= '$startDate'
AND Production.ProdDate <= '$endDate'";
if (!($result = @ mysql_query($ProdQty, $link)))
die("query failed");
$row = mysql_result($result, "Qty"); //Insert the Qty field you dolt!
return $row;
}