I would suggest, when in doubt, to work your way out and temporarily replace variables with the actual content.
In other words, replace
$connection = mysql_connect( $DBHostName, $DBUsername, $DBPassword ) or die("SQL connect error: ".mysql_error());
mysql_select_db ( $DBName ) or die("SQL select DB error: ".mysql_error());
with
$connection = mysql_connect( 'myhost', 'myusername', 'mypassword ) or die("SQL connect error: ".mysql_error());
mysql_select_db ( 'mydatabase' ) or die("SQL select DB error: ".mysql_error());
If that works or doesn't, it should help you pinpoint the problem.