wierd, i haven't had any problems, i added the build_newpost to a script of mine myself and it worked flawless (ok not creating a new thread, just post...)
the errormessage you have sounds like you have to add a global $DB_site; at the correct part of your script
or better said, does your script include the global.php so the connection to the DB is set up already?