<?php
$result = $mysqli->query(SELECT SUM(Answer) as answer FROM answers WHERE SID ='$uname'");
$Sum = $result->fetch_row();
var_dump($Sum);
?>
When executing the above code I get the following: Array ( [SUM(Answer)] => 8 )
, however, when I try to access $Sum[0]
I get the following Undefined offset: 0 and it prints nothing. I need to use this variable in an echo statement. Also, $Sum['Answer'] prints nothing, and I got a message saying undefined index Answer.