0

I downloaded a website from github and it's working fine except that it is showing warning in dashboard like this: dashboard

I want to know how to solve this. Here's the code of dashboard and line 15:

<?php require_once 'includes/header.php'; ?>

<?php 
    
$sql = "SELECT * FROM product WHERE status = 1"; 
$query = $connect->query($sql); 
$countProduct = $query->num_rows;
    
$orderSql = "SELECT * FROM orders WHERE order_status = 1";
$orderQuery = $connect->query($orderSql); 
$countOrder = $orderQuery->num_rows;
    
$totalRevenue = ""; 
while ($orderResult = $orderQuery->fetch_assoc()) {     
    $totalRevenue += $orderResult['paid'];   //line 15 
}
    
$lowStockSql = "SELECT * FROM product WHERE quantity <= 3 AND status = 1";
$lowStockQuery = $connect->query($lowStockSql); 
$countLowStock = $lowStockQuery->num_rows;
    
$userwisesql = "SELECT users.username , SUM(orders.grand_total) as
totalorder FROM orders INNER JOIN users ON orders.user_id =
users.user_id WHERE orders.order_status = 1 GROUP BY
orders.user_id";
$userwiseQuery = $connect->query($userwisesql);
$userwieseOrder = $userwiseQuery->num_rows;

$connect->close();

?>

Here's the database table orders: database

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
Vivek
  • 5
  • 4

1 Answers1

0

Try starting with $totalRevenue = 0; instead, then you're not trying to add a number to a string in the subsequent loop.

I'd guess this code was written for an older version of php which was more forgiving about mismatches between data types.

ADyson
  • 57,178
  • 14
  • 51
  • 63