The inscription script.php does not work


I have a registration script that doesn't work. It used to work but then suddenly it stopped working. I dont know what I've done or what happend. I have tried for like an hour now to find out where the problem is, but I can't seem to find it.

What happens? When I click register I don't get any errors but it doesn't upload to the database:

When I type: $res = mysql_query($query) or die ("ERROR"); it displays ERROR so I think it's related to that code:

//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    '';
//=============Data Base Information=================
$database    =    'login';

$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');

//===============End Server Configuration============

//=============Starting Registration Script==========

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

$password    =    mysql_real_escape_string($_POST['pass1']);

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

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

$rights    =    '0';


//=============To Encrypt Password===================

//============New Variable of Password is Now with an Encrypted Value========
$query = mysql_query("SELECT username FROM users WHERE username = '".$username."'");
if (mysql_num_rows($query) > 0)
    echo 'Username or email already in use.';
    if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
        $query    =  "insert into users(username,password,email,country,rights,IP,registrated)values('$username','$password','$email','$country',$rights,$IP,NOW())" ;
        $res    =    mysql_query($query);


I think you are getting the error because you are missing some quotes in your query for two columns wich really looks like not integers

'$email','$country',$rights,$IP,NOW())" //$rights and $ip doesn't have quotes

so your query would look like

"insert into users(username,password,email,country,rights,IP,registrated)values('$username','$password','$email','$country','$rights','$IP',NOW())"