get_error_message(); } else { if($Dont_Sync == "value1"){ session_write_close(); header("Location: game/map.php"); } else { session_write_close(); session_start(); //get userID from WP $_SESSION['id'] = $user->ID; $_SESSION['groupname'] = $user->ID; //get OAUTH data //SET Up map if first time logging in $pid = $_SESSION['id']; $tileSQL = "SELECT * from stepcity.tiles WHERE stepcity.tiles.user_id=" . $_SESSION['id']; //echo $tileSQL; $tileResult = mysql_query($tileSQL); if(mysql_num_rows($tileResult)==0){ //if there is no entry...essentially checking if you're starting for the first time //do this //echo "preparingDB"; for($i=0; $i<5; $i++) { for($j=0; $j<5; $j++) { $tileInsert = "INSERT INTO `stepcity`.`tiles` (`id` ,`x_coord` ,`y_coord` ,`tile` ,`progress` ,`excess_and_bonus`,`user_id`) VALUES (NULL , '$i', '$j', 'grass', '0', '0','$pid');"; $insertTileResult = mysql_query($tileInsert); } } //this initializes the steps $memberInsert = mysql_query("INSERT INTO `stepcity`.`members` (`user_id`) VALUES ('$pid');"); //this next part is to avoid rewriting the map.php page $groupInsert = mysql_query("INSERT INTO `stepcity`.`groups` (`id` ,`groupname` ,`gold` ,`crime` ,`population` ,`age` ,`daily_flag` ,`weekly_flag` ,`prev_total`)VALUES (NULL , '$pid', '0', '0', '0', 'classical_age', '0', '0', '0');"); } //redirect page header("Location: fitbit_test.php"); } } ?>