1. function get_total_adults()
  2. {
  3. $sql = "SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp";
  4. $result = mysql_query($sql) or die(mysql_error());
  5. $array = mysql_fetch_assoc($result);
  6.  
  7. return $array['number_of_adults'];
  8. }
  9.  
  10. function get_total_adults() {
  11. $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp';
  12. $result = mysql_query($sql) or die(mysql_error());
  13. // I'd throw a catchable exception (see below) rather than die with a MySQl error
  14.  
  15. return mysql_result($result, 0);
  16. }
  17.  
  18. function get_total_adults() {
  19. $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp';
  20. $result = mysql_query($sql);
  21. if (!$result) {
  22. throw new Exception('Failed to get total number of adults attending');
  23. }
  24.  
  25. return mysql_result($result, 0);
  26. }
  27.  
  28. try {
  29. $total_adults = get_total_adults();
  30. } catch(Exception $ex) {
  31. die('Whoops! An error occurred: ' . $ex->getMessage());
  32. // or even better, add to your template and dump the template at this point
  33. }
  34. // continue code