I'm put a chat on my website that has a login system. I have 3 login systems on my website in which i integrated two of them. I have not integraded the chat with the website so instead im going to have it find the username of the login system of the website and then find a different password called chatpass. This is basically the registration page for the chat once they login to the site on the settings page. They can type a password in and it will save it to a row according to the user in a column. I can care less if it is md5 or not. Can anyone help pls it is not working and i can't figure out what im doing wrong?

<? include "../pg/setup.php";?>
require ('includes/gen_inc.php');
require 'core.inc.php';
require ('includes/inc_myplayer.php');

//checking to see if the form hass been submitted or clicked
$chatusr =$_POST['userchat'];

//now converting then to md5 encryption

//here we can do alot of checks here, the length allowed, uppercase and lowercase,
//strip slashes and more
//but let just frst achieve our mission of changing password first, now we need to run a query
//we need to check if the new password and comfirmpassword do match

//now after checking to see if the two passwords do match
//we then run our query to get all result from the database
//and if the myslq_num_rows == 1, then the username and password do match
//and we can then reset the password.

$query="SELECT * FROM `players` WHERE `username`='".@mysql_real_escape_string($chatusr)."'"; 


//now we then run a query to update or reset our password
$query="UPDATE `players` SET `chatpass`='".@mysql_real_escape_string($chatpass_harsh)."' WHERE `username`='".@mysql_real_escape_string($chatusr)."'";

echo 'You sucessfully set your chat password';
echo 'There was an error processing your password';

echo 'New password and comfirm password do not match';

echo 'All fileds are required';
I used pastebin because i was limited on how many characters im allowed to use