2
I am trying to sum up a column using the mysqli SUM method. The problem is that my query does not return results. My code is this:
$sql = 'SELECT SUM(size) as soma, porta FROM `'
.$this->options['db_table'].'` WHERE `porta`=?';
$query = $this->db->prepare($sql);
$query->bind_param('s', $file->porta);
$query->execute();
$query->bind_result(
$soma
);
$query->close();
echo $soma;
What could be wrong? Remembering that all other queries without using SUM() work perfectly.
Really! Inserting $query->fetch() worked, but I also had to change from "SUM(size) the sums, port" to just "SUM(size) the sums" and it turned out all right.
– anderson