SQL在PHP中将SUM作为INT返回

I have a SQL query that returns SUM, and I need to use that SUM later on to sum it to another field in PHP, so I could return the TotalSum (old points + new points) to the database, but I get the following error:

Object of class mysqli_result could not be converted to int

It doesn't add these values that I fetch from database.

My code is:

$Sum1= mysqli_query($con, "SELECT SUM(`Points`) FROM `table` WHERE `Id`=$ID ");
$Sum2= mysqli_query($con, "SELECT SUM(`PointsTwo`) FROM `table` WHERE `Id`=$ID");

$TotalSum=$Sum1+ $Sum2+ $NewPoints+ $NewPointsTwo;

I would like to point out that values in the columns are integers

You need to first fetch the result of your query like so:

$Sum1= mysqli_query($con, "SELECT SUM(`Points`) FROM `table` WHERE `Id`=$ID ");
$row = mysqli_fetch_array($Sum1);

// $row now contains all the column values for the query
$TotalSum = $row[0] + ...

Check out this tutorial for more info on using the mysqli functions.