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

Connected successfully

"; } catch (PDOException $e) { // failed connection echo "Connection failed: " . $e->getMessage(); } ////////// USER DATA /////////// echo "

Creating user data table...

"; // 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!

"; //////// REPLAY DATA //////// echo "

Creating replay data table...

"; // Check if the replay data table exists already $sqlCheckDataTable = $conn->prepare("SHOW TABLES LIKE '" . $dataTableName . "'"); // 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 '" . $dataTableName . "'...

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

Deleted!

Creating new table '" . $dataTableName . "'...

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

Table '" . $dataTableName . "' successfully created (replay 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 '" . $dataTableName . "' successfully created (replay data)

"; } catch (PDOException $e) { echo $sqlCreateDataTable . "
" . $e->getMessage(); } } //////// TROPHY DATA //////// echo "

Creating trophy data table...

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

Deleting exsiting table '" . $trophyTableName . "'...

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

Deleted!

Creating new table '" . $trophyTableName . "'...

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

Table '" . $trophyTableName . "' successfully created (trophy data)

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

Table '" . $trophyTableName . "' successfully created (trophy data)

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

DONE!

"; ?>