I am trying to get the SUM of a column SnappersScore from a table LastResult. However, there is nothing in the output at all. Not even an error. Any ideas about what I am doing wrong?
Here it is:
<?php
mysql_connect(xxxxxx);
if (mysql_connect_errno())
{
echo "Failed to connect to MySQL: " . mysql_connect_error();
}
$result = mysql_query('SELECT SUM(SnappersScore) AS TotalGoals FROM LastResult');
$row = mysql_fetch_assoc($result);
$sum = $row['TotalGoals'];
echo $sum;
?>
mysql_*functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.