Problems with Flash/PHP 'Change Password' script

Hi there,

I am a newbie, and I have been really struggling with Flash AS/PHP scripts that allows a logged in user to change their password. I use an almost identical system for registration and login, and without any problem.
The problem is as follows; when the user enters their new password into the Flash input field (called ‘pass’) and presses the ‘submit’ button, I am not sure if the variable gets passed to the PHP script. In any case, the only feedback I get from the PHP script is that it could not connect with the database.
Does anyone out there in PHP-land have any idea what the problem might be?

Here is the code, for reference sake (Please excuse its crudeness, but I am still learning to use Flash and PHP);

Actionscript (Flash 8) on the submit button;

on (release, keyPress "<Enter>") {
    if (pass != "") {
        status = "Initiating Process - Stand By";

        loadVariablesNum("*(my url)*/members/new_pass.php", 0, "POST");
        gotoAndPlay(3);
    }
}

The input field variable is called ‘pass’ and there is a dynamic text field with the variable ‘status’.

The PHP code for the new_pass.php file is as follows;

<?php
ob_start();
session_start();

include('(my url)/templates/mysql_connect.php');

$pass = $_POST["pass"];

if ($pass){

       mysql_connect($DBhost,$DBuser,$DBpass)or die("Could not connect to database. MySQL said: ".mysql_error());
           mysql_select_db("$DBName")or die("Could not select the database. MySQL said: ".mysql_error());
              $query = "UPDATE members SET userpassword=$pass WHERE username={$_SESSION['username']}";
              $result = mysql_query($query)or die("The query failed. MySQL said: ".mysql_error());
                    if (mysql_affected_rows() == 1) {
                           print "_root.status=Password changed&_root.checklog=1";
                           exit();

            } else {

            print "_root.status=Password could not be updated&_root.checklog=2";

            }

      }

else {

print "_root.status=Problem connecting to database&_root.checklog=3";

}

ob_end_flush();
?>

Finally, the mysql_connect.php file is as follows;

<?php

$DBhost = "www.(my url).com";
$DBuser = "orpheus7";
$DBpass = "peter_pan";
$DBName = "game_db";

?>

I have altered the passwords, host and urls for security reasons.

Any help with this would be most appreciated. Thanks for your time.