I'm sure you all are tired of me already however.... here I go again

I've stuck my rather long code at the bottom of this. But reader's digest condensed version:
I'm setting up a registration form. I want query the user table to see if the user name already exists and if not then exit. If the user name is available then check a ship name to see if it already exists. Both fields are set to unique in the table btw. There are no records in the table at present.
However, no matter what I put in it tells me the user name is not available. Which I know it should be. I put in echo checks to ensure the form data is being passed and the correct values are being shown so the $_POST info is setting the variable.
This is the snippet of code that I am doing the check with
CODE
$query=" SELECT * FROM users WHERE `user_name` = '$user'";
$mysqli->query($query);
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$row=$result->fetch_object();
$row_user_name=$row->user_name;
if ($row_user_name = $user)
{
printf("Sorry but character name %s is already taken.", $user);
exit();
}
I am using a similar version to check the ship name.
The syntax from the reference books I have seems to be correct but obviously something is horribly wrong. The $row_user_name and $row_vessel_name variables should both have nothing in them from the empty table.
Am I on the right track here?
Here is the full code leaving out the stupid long list of variables.
CODE
if ($password != $confirm)
{
print("<span style='color:red'>ERROR: Passwords do not match! </span>");
}
$mysqli = new mysqli($host, $dbuser, $pw, $db);
if ( $mysqli->errno)
{
printf("Unable to connect to the database: <br /> %s", $mysqli->error);
exit();
}
$query=" SELECT * FROM users WHERE `user_name` = '$user'";
$mysqli->query($query);
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$row=$result->fetch_object();
$row_user_name=$row->user_name;
if ($row_user_name = $user)
{
printf("Sorry but character name %s is already taken.", $user);
exit();
}
$query=" SELECT * FROM users WHERE `vessel_name` = '$vessel_name'";
$mysqli->query($query);
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$row=$result->fetch_object();
$row_vessel_name=$row->vessel_name;
if ($row_vessel_name = $vessel_name)
{
printf("Sorry but there is already a vessel named %s.", $vessel_name);
exit();
}
$query="INSERT INTO users (`user_name`, `password`, `rank`, `affiliation`, `admin`, `subscription`, `beta_test`, `email`, `country`, `points`, `wins`, `losses`, `vessel_name`, `pos_x`, `pos_y`, `class`, `point_value`, `shield`, `max_shield`, `heavy_weapon`, `max_heavy_weapon`, `main_phaser`, `max_main_phaser`, `defensive_phaser`, `max_defensive_phaser`, `hull`, `max_hull`, `lab`, `max_lab`, `trans`, `max_trans`, `bridge`, `max_bridge`, `sub_light_engines`, `max_sub_light_engines`, `auxillary_power`, `max_auxillary_power`, `battery_power`, `max_battery_power`, `small_craft`, `max_small_craft`, `extra_damage`, `max_extra_damage`, `light_engines`, `max_light_engines`, `NOT_USED`, `NOT_USED1`, `NOT_USED2`, `NOT_USED3`, `NOT_USED4`, `NOT_USED5`, `NOT_USED6`, `NOT_USED7`, `NOT_USED8`, `NOT_USED9`, `NOT_USED10`, `NOT_USED11`) VALUES ('$user',
'$password',
'$confirm',
'$faction',
'$email',
'$vessel_name',
'$rank',
'$admin',
'$subscription',
'$beta_test',
'$class',
'$country',
'$points',
'$wins',
'$losses',
'$point_value',
'$pos_x',
'$pos_y',
'$shield'
'$max_shield',
'$heavy_weapon',
'$max_heavy_weapon'
'$main_phaser',
'$max_main_phaser',
'$defensive_phaser',
'$max_defensive_phaser',
'$hull',
'$max_hull',
'$lab',
'$max_lab',
'$trans',
'$max_trans',
'$bridge',
'$max_bridge',
'$sub_light_engines',
'$max_sub_light_engines',
'$auxillary_power',
'$max_auxillary_power',
'$battery_power',
'$max_battery_power',
'$small_craft',
'$max_small_craft',
'$extra_damage',
'$max_extra_damage',
'$light_engines',
'$max_light_engines',
'$NOT_USED',
'$NOT_USED1',
'$NOT_USED2',
'$NOT_USED3',
'$NOT_USED4',
'$NOT_USED5',
'$NOT_USED6',
'$NOT_USED7',
'$NOT_USED8',
'$NOT_USED9',
'$NOT_USED10',
'$NOT_USED11');";
$mysqli->query($query);
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
}
?>