Hello
Here are a call to a function
$items_l = get_all_profit($start_date, $end_date, $hour_start, $hour_end, $days);
and a function
function get_all_profit($start_date, $end_date, $hour_start, $hour_end, $days)
{
global $db;
try
{
$sql = "SELECT c_time, o_time, profit, hideshow, DATE_FORMAT(c_time, '%m-%y') AS time
FROM data
WHERE c_time BETWEEN :start_date AND :end_date
AND TIME(`o_time`) BETWEEN :hour_start AND :hour_end
AND WEEKDAY(`o_time`) IN ($days)
AND hideshow = 'hide'
ORDER BY c_time ASC";
$stmt = $db->prepare($sql);
$stmt->bindParam(':start_date', $start_date, PDO::PARAM_STR);
$stmt->bindParam(':end_date', $end_date, PDO::PARAM_STR);
$stmt->bindParam(':hour_start', $hour_start, PDO::PARAM_STR);
$stmt->bindParam(':hour_end', $hour_end, PDO::PARAM_STR);
$stmt->execute();
if($stmt->rowCount() == 0)
return 0;
else
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
return false;
}
}//End function
I get these errors:
- Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_all_profit(), 1 passed in C:\wamp\www\trade_analyzer_filter_NEWֹTABLESֹ\trades_header.php on line 113 and exactly 5 expected
and
2. ArgumentCountError: Too few arguments to function get_all_profit(), 1 passed in C:\wamp\www\trade_analyzer_filter_NEWֹTABLESֹ\trades_header.php on line 113 and exactly 5 expected
Whem I call the function without agruments and the function looks like that
function get_all_profit()
{
global $db;
try
{
$sql = "SELECT c_time, o_time, profit, hideshow, DATE_FORMAT(c_time, '%m-%y') AS time
FROM data
WHERE hideshow = 'hide'
ORDER BY c_time ASC";
$stmt = $db->prepare($sql);
$stmt->execute();
if($stmt->rowCount() == 0)
return 0;
else
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
return false;
}
}//End function
It works well.
I have a few more functions which work well when the call to the function passes 5 variables and the function gets 5 variables so there is no problem with the variables or their values
So where is the problem?
What is the solution