I am trying to add all the values in a single column from a table and then echo that value
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT sum(paid) as total_paid from users";
$result = $conn->query($sql);
echo $result;
But I end up getting this error:
Catchable fatal error: Object of class mysqli_result could not be converted to string in
Why and how can I fix?