int varchar
+======+==========+
| id | amount |
+======+==========+
| 1 | 1.40 |
| 2 | 2.40 |
| 3 | 3.40 |
+======+==========+
$res += $row['amount'];
// $res = 6
$res += (float)$row['amount'];
// $res = 6
how come i can’t add them?
According your var_dump results
string(8) "1,000.00" string(8) "2,391.45" string(8) "2,005.31", this is the problem of your data.(float)"2,391.45"will cast the stringstring("2,391.45")tofloat(2)