Hey

Just comment-out the line
//echo "$key: $val<br />";//debugging info

The script can send HTTP headers only before any output. This should help.

It worked on your previous host because default PHP error level was not showing all script errors. However on GlowHost servers PHP will show all errors, unless specified other option. This is good, because you can debug your scripts & see all errors they're causing.