setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "

Connected successfully

"; } catch (PDOException $e) { // failed connection echo "Connection failed: " . $e->getMessage(); } ////////// USER DATA /////////// // Check if the users table exists already $sqlCheckUserTable = $conn->prepare("SHOW TABLES LIKE '" . $userTableName . "'"); // Run the query $sqlCheckUserTable->execute(); //Check if any rows exist - if not, create the table, if yes, destroy it first, then create it $count = $sqlCheckUserTable->rowCount(); if ($count != 0) { echo "

Deleting exsiting table '" . $userTableName . "'...

"; // Create the query to drop the table $sqlDropUserTable = "DROP TABLE " . $userTableName; $conn->exec($sqlDropUserTable); // drop the table echo "

Deleted!

Creating new table '" . $userTableName . "'...

"; try { // Create the new table $conn->query($sqlCreateUserTable); echo "

Table '" . $userTableName . "' successfully created (user data)

"; } catch (PDOException $e) { echo $sqlCreateUserTable . "
" . $e->getMessage(); } } else { // If the table doesn't already exist, we'll just create it try { $conn->query($sqlCreateUserTable); echo "

Table '" . $userTableName . "' successfully created (user data)

"; } catch (PDOException $e) { echo $sqlCreateUserTable . "
" . $e->getMessage(); } } // Next we're going to copy any safe admins into the users table. // This will make userlists easier to work with echo "

Copying users from safe admins...

"; $copyAdmins = $conn->prepare("INSERT INTO " . $userTableName . " SELECT * FROM " . $adminUserTableName); $copyAdmins->execute(); echo "

Copied!

"; //////// GAME DATA //////// // Check if the replay data table exists already $sqlCheckDataTable = $conn->prepare("SHOW TABLES LIKE '" . $gameDataTableName . "'"); // Run the query $sqlCheckDataTable->execute(); //Check if any rows exist - if not, create the table, if yes, destroy it first, then create it $count = $sqlCheckDataTable->rowCount(); if ($count != 0) { echo "

Deleting exsiting table '" . $gameDataTableName . "'...

"; // Create the query to drop the table $sqlDropDataTable = "DROP TABLE " . $gameDataTableName; $conn->exec($sqlDropDataTable); // drop the table echo "

Deleted!

Creating new table '" . $gameDataTableName . "'...

"; try { // Create the new table $conn->query($sqlCreateDataTable); echo "

Table '" . $gameDataTableName . "' successfully created (saved game data)

"; } catch (PDOException $e) { echo $sqlCreateDataTable . "
" . $e->getMessage(); } } else { // If the table doesn't already exist, we'll just create it try { $conn->query($sqlCreateDataTable); echo "

Table '" . $gameDataTableName . "' successfully created (saved game data)

"; } catch (PDOException $e) { echo $sqlCreateDataTable . "
" . $e->getMessage(); } } //////// TOURNAMENT DATA //////// // Check if the replay data table exists already $sqlCheckTournamentTable = $conn->prepare("SHOW TABLES LIKE '" . $tournamentDataTableName . "'"); // Run the query $sqlCheckTournamentTable->execute(); //Check if any rows exist - if not, create the table, if yes, destroy it first, then create it $count = $sqlCheckTournamentTable->rowCount(); if ($count != 0) { echo "

Deleting exsiting table '" . $tournamentDataTableName . "'...

"; // Create the query to drop the table $sqlDropTournamentTable = "DROP TABLE " . $tournamentDataTableName; $conn->exec($sqlDropTournamentTable); // drop the table echo "

Deleted!

Creating new table '" . $tournamentDataTableName . "'...

"; try { // Create the new table $conn->query($sqlCreateTournamentTable); echo "

Table '" . $tournamentDataTableName . "' successfully created (tournament data)

"; } catch (PDOException $e) { echo $sqlCreateTournamentTable . "
" . $e->getMessage(); } } else { // If the table doesn't already exist, we'll just create it try { $conn->query($sqlCreateTournamentTable); echo "

Table '" . $tournamentDataTableName . "' successfully created (tournament data)

"; } catch (PDOException $e) { echo $sqlCreateTournamentTable . "
" . $e->getMessage(); } } $conn = null; // Close the connection // Tell the user we're done echo "

DONE!

"; } ?>