I am getting the error:
Object of class mysqli_result could not be converted to string.
Code:
You cannot directly output the result of a query. Use:
$sql = ("select sum(`memory`) AS memTotal from `server`");
// Show used memory
$result = mysqli_query($con, $sql);
echo $result->fetch_object()->memTotal;
The $result
variable holds an object (of type mysqli_result), from which you can fetch the scalars you need to output.
$result
is a result object. From thje manual for mysqli_query():
Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.