Re: PHP in my header.php causing signup errors
Buddypress is not unusable software. I suggest being a bit more polite if you come looking for help, especially to the official Buddypress forums.
It’s because you’re trying to shoehorn a PHP script into your theme. Either one of the PHP variables you use in the snippet in bold is used elsewhere by Buddypress – thus getting weird conflicts – or it’s to do with one of your mysql_ function calls, possibly mysql_select_db().