Fix issue when seconds is greater than two digits.

Also only use one query rather than a loop.
Report properly when value is undefined (slave error).
Merge pull request #543 from colinmollenhour/patch-1

Fix issue when seconds is greater than two digits.