I keep getting this error even though when I view my cart it lists the item and price and then the total price is calculated and returned with the right value. I am not sure what the error is because it lists everything correctly with the product title and it's price. I do know understand why it is say a non-numeric value because the price is listed and the total price is added up correectly.
<!DOCTYPE html>
<html>
<head>
<title>Cart</title>
</head>
<body>
<?php
session_start();
require_once('connect.php');
include('cartHead.php');
include('cartNav.php');
?>
<div class="container">
<?php
$items = $_SESSION['cart'];
$cartitems = explode(",", $items);
?>
<div class="row">
<table class="table">
<tr>
<th>Item</th>
<th>Item Name</th>
<th>Price</th>
</tr>
<?php
$total = '';
$i=1;
foreach ($cartitems as $key=>$id) {
$sql = "SELECT * FROM products WHERE id = $id";
$res=mysqli_query($connect, $sql);
$r = mysqli_fetch_assoc($res);
?>
<tr>
<td><?php echo $i; ?></td>
<td><a href="delCart.php?remove=<?php echo $key; ?
>">Remove</a> <?php echo $r['title']; ?></td>
<td>$<?php echo $r['price']; ?></td>
</tr>
<?php
$total = $total + $r['price'];
$i++;
}
?>
<tr>
<td><strong>Total Price</strong></td>
<td><strong>$<?php echo $total; ?></strong></td>
<td><a href="#" class="btn btn-info">Checkout</a></td>
</tr>
</table>
</div>
</div>
<?php include('cartFooter.php'); ?>
</body>
</html>