Skip to content

dashboard.php #15 #34

Description

@cata25tm

$totalRevenue += $orderResult['paid'];
In this line, you're trying to add a value to $totalRevenue, which is initially an empty string, and $orderResult['paid'], which may also be a string based on your database's configuration.

To fix this issue, you can initialize $totalRevenue to 0, which is a number. And ensure that $orderResult['paid'] is also a number before performing the addition operation.

$totalRevenue = 0;
while ($orderResult = $orderQuery->fetch_assoc()) {
	$totalRevenue += floatval($orderResult['paid']);
}

In the code snippet above, I initialized $totalRevenue to 0 instead of an empty string. And to make sure that $orderResult['paid'] is a number, I used the floatval() function which converts a variable to a float. If $orderResult['paid'] is a string representing a number, floatval() will convert it to a float so that the addition can proceed.

If your 'paid' field can contain decimal values, using floatval() is the right choice. If it's always a whole number, you could use intval() instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions