使用mysql_real_escape_string成功插入新记录后获取空白字段

I insert new records to a MySQL database/table using PHP and every thing is fine. Collation of DB and tables are utf8_unicode_ci. Here is the insertion code:

if($_SERVER['REQUEST_METHOD'] = "POST") 
{
    $category = mysql_real_escape_string($_POST['category']);

    mysql_connect('localhost', 'xxx','xxxx') or die(mysql_error()); //Connect to server
    mysql_select_db('xxxx') or die("Cannot connect to database"); //Connect to database

    mysql_query("INSERT INTO categories (category) VALUES ('$category')"); //SQL query
    header("location: home.php");
}
else
{
    header("location:home.php"); //redirects back to home
}

I create same database in my hosting service, I use WAMP/phpMyAdmin/Export + data. Every thing looks fine in my hosting/phpMyAdmin and the records are there in tables. Collations are the same. BUT when I try to insert a record, the new text fields are blank, I have a new record with new id but text field content is empty. No error message. There is a warning:

Warning: mysql_real_escape_string(): Access denied for user 'yyyy'@'localhost' (using password: NO) in /home/yyyyyy/public_html/xxxxx/add.php on line 12

'yyyy' is a different name from xxxx in mysql_select_db('xxxx') that I do not know where is it coming from?

Check to see if $category is null

if($_SERVER['REQUEST_METHOD'] ==  "POST" && isset($_POST['category'])) 
{
    $category = mysql_real_escape_string($_POST['category']);

    mysql_connect('localhost', 'xxx','xxxx') or die(mysql_error()); //Connect to server
    mysql_select_db('xxxx') or die("Cannot connect to database"); //Connect to database

    mysql_query("INSERT INTO categories (category) VALUES ('$category')"); //SQL query
    //header("location: home.php");
    echo 'successful'
}
else
{
    //header("location:home.php"); //redirects back to home
    echo 'problem'
}

Also fix:

 if($_SERVER['REQUEST_METHOD'] = "POST") 

To

 if($_SERVER['REQUEST_METHOD'] == "POST") 

Try this mysql_query("INSERT INTO categories (category) VALUES ('" . $category . "')");

I simply brought these two line befor mysql_real_escape_string

mysql_connect('localhost', 'xxx','xxxx') or die(mysql_error()); //Connect to server
mysql_select_db('xxxx') or die("Cannot connect to database"); //Connect to database


$category = mysql_real_escape_string($_POST['category']);

and it is working fine!