I have this code:
<?php
$con = mysql_connect(DB_HOST, DB_USER, DB_PASS);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(DB_NAME, $con);
$result = mysql_query("SELECT SUM(colname) FROM profits");
$total = reset (mysql_fetch_assoc($result));
mysql_close($con);
echo $total;
?>
And its outputting an Resource id #5. Any help? Thanks in advance!
Don’t use
reset()like that – if you need a single value, just uselist():reset()does not work as you expect on associative arrays: https://bugs.php.net/bug.php?id=38478