This query `
delimiter $$
CREATE DEFINER=`root`@`localhost` FUNCTION `calculatePrice`(cheese VARCHAR(50), meat VARCHAR(50), veg VARCHAR(50)) RETURNS decimal(10,0)
DETERMINISTIC
BEGIN
DECLARE price DECIMAL;
SET price = (SELECT SUM(x.Price)
FROM
(
SELECT `priceFactor` AS Price FROM `tblCheese` WHERE `cheeseName` = cheese
UNION ALL
SELECT `priceFactor` AS Price FROM `tblMeat` WHERE `meatName` = meat
UNION ALL
SELECT `priceFactor` AS Price FROM `tblVeggie` WHERE `veggieName` = veg
) x );
RETURN price;
END$$
`
is returning the mathematically-correct answer when called from the MySQL command-line client, but incorrect for any other program or when called from PHP (it's returning 3 there, no matter what parameters are passed.) See below:

The calling statement, in case it's blurry, is SELECT calculatePrice('colby', 'sausage', 'black beans');
I've never seen this weirdness before. It's all going off of the same copy of MySQL, etc.
Edit to add: phpMyAdmin also yields the correct answer to the query.