The bug I was seeing (in the latest Firebird on OS X 10.2) was that the
page wasn't refreshing. I added code to COM_refresh to emit the
location header as well as the HTML, then exit immediately to prevent
other code from running and emitting bad data, and it works fine. This
breaks the general design principle of having routines return HTML, so
YMMV.
function COM_refresh( $url )
{
header("Location: $url");
print "<html><head><meta http-equiv=\"refresh\" content=\"0;
URL=$url\"></head></html>\n";
exit;
}