-CUR_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$MARK\" and result = 'fail';"`
-OLD_FAIL=`/usr/bin/php4 -c /etc/php4/apache/php.ini -f $SHELLADDERPHP -- $COMMONPHP "select count(distinct test) from bench where mark = \"$LASTMARK\" and result = 'fail';"`
+#check for more broken tests
+CUR_FAIL=`printf "$SQLQFAILCOUNT" "$MARK" | $MYSQL | tail -n 1`
+OLD_FAIL=`printf "$SQLQFAILCOUNT" "$LASTMARK" | $MYSQL | tail -n 1`
+
+if [ "$CUR_FAIL" -gt "$OLD_FAIL" ]; then
+ TMP1=`mktemp`
+ TMP2=`mktemp`
+ TMP3=`mktemp`
+ printf "$SQLQFAIL" "$MARK" | $MYSQL > $TMP1
+ printf "$SQLQFAIL" "$LASTMARK" | $MYSQL > $TMP2
+ combine $TMP1 not $TMP2 > $TMP3