I am trying to make a stored procedure for a MySQL database. The stored procedure is supposed to grab the amount of money each employee has spent on a specific items for lunch. The issue that I am running into is that I cannot get the stored procedure to return any values. When I run it as a SQL query and input a date where my variable is supposed to be it works fine. I am using MySQL. Here is my stored procedure:
DELIMITER $$
CREATE PROCEDURE `class`.`PricePaid`(varBeginningDate DATE)
BEGIN
SELECT Item_Desc, SUM( Item_Price ) AS 'Total Price Paid'
FROM Lunch, Item, Lunch_item
WHERE Lunch.Lunch_id = Lunch_item.Lunch_id
AND Item.Item_Number = Lunch_item.Item_Number
AND DATEDIFF(Lunch.Lunch_Date, "'" + varBeginningDate + "'") > 0
GROUP BY Item.Item_Desc;
END
My php code calling the function is this
<?php
include("Functions.php");
if(isset($_POST['SubmitPricePaid'])){
$strSQL = "CALL `class`.`PricePaid`('{$_POST[$PricePaidDate]}');";
}
?>
<?php if(isset($_POST['SubmitPricePaid'])){
print_report($strSQL, $db);
}
?>
Lets begin with the debugging:
<?php
include("Functions.php");
if(isset($_POST['SubmitPricePaid'])){
$strSQL = "CALL `class`.`PricePaid`('{$_POST[$PricePaidDate]}');";
var_dump($strSQL);
var_dump($db);
exit(); //EDITED
print_report($strSQL, $db);
}
?>
Can you post the results of var_dump...i need to see those results
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.