Hello.
For some reason I can't seem to fathom, once this code checks that no one else is using the same user name, vessel name, and email address, it writes the record to the table.
However, it is writing the record TWICE. I have to be honest, I have absolutely no clue why. I have stared at this most of last night and a good chunk of today.
Anyone see anything that might explain this?
I've left out the multitude of variables and the setting of their values. Some are from $_POST and others are set directly.
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` = CONVERT(_utf8 '$user' USING latin1) COLLATE latin1_swedish_ci";
$mysqli->query($query);
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
if ($result->num_rows > 0)
{
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();
}
if ($result->num_rows > 0)
{
printf("Sorry but vessel name %s is already taken.", $vessel_name);
exit();
}
$query=" SELECT * FROM users WHERE `email` = '$email'";
$mysqli->query($query);
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
if ($result->num_rows > 0)
{
printf("Sorry but a player is already using %s as an email address.", $email);
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',(md5('$password')),'$rank', '$faction','$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');";
$mysqli->query($query);
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
Code after this point sends a confirmation email and then prints out a fun YOU ARE GIVEN COMMAND message to the screen.
Thanks for any help.