init_tables.php 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // Description:
  3. // This script will create the table required by the metaserver.
  4. // 1. Edit the config.php file;
  5. // 2. Upload and run this script once;
  6. // 3. Remove this script from the metaserver.
  7. // No parameter.
  8. // Returns:
  9. // - if an error occurs, "error" followed by an explanation;
  10. // - if it works, an empty page.
  11. // End of description.
  12. // The code starts here...
  13. require("config.php");
  14. // connect to the database
  15. $link = mysql_connect($dbhost, $dbuser, $dbpasswd)
  16. or die("error: connexion to database failed");
  17. mysql_select_db($dbname)
  18. or die("error: could not select database");
  19. // create the "soundrts_servers" table
  20. $query = "CREATE TABLE soundrts_servers (time INT UNSIGNED NOT NULL, ip VARCHAR(40) NOT NULL, version VARCHAR(52) NOT NULL, login VARCHAR(20) NOT NULL, port INT UNSIGNED NOT NULL)"; // 52 = 20 + 32 (optional MD5 hexdigest)
  21. $result = mysql_query($query)
  22. or die('error: query failed: '.mysql_error());
  23. // disconnect from the database
  24. mysql_close($link);
  25. ?>