It prints out 0 because obviously there isn't an acount for $getuser. To check if a user already exists, what you want to use is something like this:
$name = $_POST['user'];
$exist = mysql_query("SELECT * FROM players WHERE name='$name'");
$result = mysql_num_rows($exist);
if ($result == 0)
{
echo "User already exists!";
}
else
{
echo "That name is not in use by anybody.";
}
Use this for second part:
$useron = $_SESSION['user'];
$blah1 = mysql_query("SELECT * FROM login WHERE user='$useron'");
while ($data1 = mysql_fetch_array($blah1))
{
$player1 = $data1['player1'];
$player2 = $data1['player2'];
}
//Create the new character in Player1 if there is nothing in there.
if ($player1 < 0)
{
$add_user = "INSERT INTO players (name, account, race, str, con, dex, qui, piety, intel, chp, x, y, cmana, csta, level, exp, cweight) VALUES ('".$_POST['name']."', '".$_SESSION['user']."', '".$_POST['race']."', '$str', '$con', '$dex', '$qui', '$piety', '$intel', '$chp', '500', '500', '$cmana', '$stamina', '1', '0', '0' )";
mysql_query($add_user) or die(mysql_error());
mysql_query("UPDATE login set player1= '".$_POST['name']."' where user='$useron'");
}
//Something is in Player1!? Oh no! Try to put it in player2!
if(($player1 > 0) && ($player2 < 0))
{
$add_user = "INSERT INTO players (name, account, race, str, con, dex, qui, piety, intel, chp, x, y, cmana, csta, level, exp, cweight) VALUES ('".$_POST['name']."', '".$_SESSION['user']."', '".$_POST['race']."', '$str', '$con', '$dex', '$qui', '$piety', '$intel', '$chp', '500', '500', '$cmana', '$stamina', '1', '0', '0' )";
mysql_query($add_user) or die(mysql_error());
mysql_query("UPDATE login set player2= '".$_POST['name']."' where user='$useron'");
}
//Awww the user already has two characters, so don't create the character.
if(($player1 > 0) && ($player2 > 0))
{
echo "You already have two characters in use already. Couldn't create the player.";
}
See what that does for you.