function get_total_adults() { $sql = "SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp"; $result = mysql_query($sql) or die(mysql_error()); $array = mysql_fetch_assoc($result); return $array['number_of_adults']; } function get_total_adults() { $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp'; $result = mysql_query($sql) or die(mysql_error()); // I'd throw a catchable exception (see below) rather than die with a MySQl error return mysql_result($result, 0); } function get_total_adults() { $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp'; $result = mysql_query($sql); if (!$result) { throw new Exception('Failed to get total number of adults attending'); } return mysql_result($result, 0); } try { $total_adults = get_total_adults(); } catch(Exception $ex) { die('Whoops! An error occurred: ' . $ex->getMessage()); // or even better, add to your template and dump the template at this point } // continue code