"); echo "\nSuccessfully wrote \"$config_path\"\n"; } $check = readline("Automatically create tables? [Y/n] "); if($check != "n"){ print "\n"; print "Testing connection using credentials..."; include "backend/config.php"; print "\tSuccess!\n"; GLOBAL $database; $tables = [ "Classes" => "CREATE TABLE IF NOT EXISTS Classes ( ID int(11) NOT NULL AUTO_INCREMENT, Name varchar(255) DEFAULT NULL, Code varchar(255) NOT NULL, Location tinyint(1) DEFAULT NULL, Link varchar(255) DEFAULT NULL, Hidden tinyint(1) DEFAULT '0', PRIMARY KEY (ID))", "Assignments" => "CREATE TABLE IF NOT EXISTS Assignments ( ID int(11) NOT NULL AUTO_INCREMENT, Class_ID int(11) NOT NULL, Due_date date DEFAULT NULL, Alt_due_date varchar(255) DEFAULT NULL, Description varchar(1024) NOT NULL, Color varchar(255) DEFAULT NULL, Highlight varchar(255) DEFAULT NULL, Done tinyint(1) DEFAULT NULL, Link varchar(255) DEFAULT NULL, Hidden tinyint(1) DEFAULT '0', PRIMARY KEY (ID))" ]; foreach(array_keys($tables) as $key){ print "Creating table \"$key\"..."; $q = $tables[$key]; if(mysqli_query($db, $q)) print "\tSuccess!\n"; else die("$q\nInsertion Failed: " . mysqli_error($db) . "\n"); } } function fwrite_wrapper($file, $string){ GLOBAL $config_path; if(fwrite($file, $string) === FALSE){ die("Cannot write to file \"$config_path\""); } } ?>