SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem importing tables

    I found an old program (2003) called "mypbs" to keep track of stats for my baseball team.
    To set it up the it states to do the following :

    Create a database
    1. Create a mysql database
    2. Use the mypbs.sql file to create the database tables


    to do this, I opened MySQL and imported the sql-file (I provided the sql-file below)
    The tables are created, but when I look at a table it seems to give an error.
    The message i recieve says:
    PRIMARY and INDEX keys should not both be set for column `id`

    when I run the php-script to add items (season, players, etc.), and try to add things, it just gives an error and nothing is added to the tables in MySQL.

    Is there an error in the sql script to create the tables? if so, can anyone help me to fix this or create a php-script to add the tables thru php?

    thanks, Gert


    Code SQL:
    #
    # TABLE STRUCTURE FOR TABLE `batting`
    #
     
    CREATE TABLE batting (
      id mediumint(5) NOT NULL AUTO_INCREMENT,
      playerID mediumint(5) DEFAULT NULL,
      gameID mediumint(5) DEFAULT NULL,
      seasonID mediumint(5) DEFAULT NULL,
      pa tinyint(8) DEFAULT NULL,
      bb tinyint(8) DEFAULT NULL,
      sol tinyint(8) DEFAULT NULL,
      sos tinyint(8) DEFAULT NULL,
      runs tinyint(8) DEFAULT NULL,
      1b tinyint(8) DEFAULT NULL,
      2b tinyint(8) DEFAULT NULL,
      3b tinyint(8) DEFAULT NULL,
      hr tinyint(8) DEFAULT NULL,
      rbi tinyint(8) DEFAULT NULL,
      sac tinyint(8) DEFAULT NULL,
      hbp tinyint(8) DEFAULT NULL,
      obe tinyint(8) DEFAULT NULL,
      steals tinyint(8) DEFAULT NULL,
      PRIMARY KEY  (id),
      UNIQUE KEY id (id)
    ) TYPE=MyISAM;
    # --------------------------------------------------------
     
    #
    # TABLE STRUCTURE FOR TABLE `games`
    #
     
    CREATE TABLE games (
      gameID mediumint(5) NOT NULL AUTO_INCREMENT,
      seasonID mediumint(5) DEFAULT NULL,
      DATE DATE DEFAULT NULL,
      team VARCHAR(25) DEFAULT NULL,
      PRIMARY KEY  (gameID),
      UNIQUE KEY gameID (gameID)
    ) TYPE=MyISAM;
    # --------------------------------------------------------
     
    #
    # TABLE STRUCTURE FOR TABLE `pitching`
    #
     
    CREATE TABLE pitching (
      id mediumint(5) NOT NULL AUTO_INCREMENT,
      playerID mediumint(5) DEFAULT NULL,
      gameID mediumint(5) DEFAULT NULL,
      seasonID mediumint(5) DEFAULT NULL,
      win tinyint(5) DEFAULT NULL,
      loss tinyint(5) DEFAULT NULL,
      save tinyint(5) DEFAULT NULL,
      nd tinyint(5) DEFAULT NULL,
      ip FLOAT DEFAULT NULL,
      runs tinyint(5) DEFAULT NULL,
      er tinyint(5) DEFAULT NULL,
      bb tinyint(5) DEFAULT NULL,
      sol tinyint(5) DEFAULT NULL,
      sos tinyint(5) DEFAULT NULL,
      batters tinyint(5) DEFAULT NULL,
      hits tinyint(5) DEFAULT NULL,
      hr tinyint(5) DEFAULT NULL,
      gs tinyint(5) DEFAULT NULL,
      hbp tinyint(5) DEFAULT NULL,
      shut tinyint(5) DEFAULT NULL,
      PRIMARY KEY  (id),
      UNIQUE KEY id (id)
    ) TYPE=MyISAM;
    # --------------------------------------------------------
     
    #
    # TABLE STRUCTURE FOR TABLE `players`
    #
     
    CREATE TABLE players (
      playerID mediumint(5) NOT NULL AUTO_INCREMENT,
      LAST VARCHAR(25) DEFAULT NULL,
      FIRST VARCHAR(25) DEFAULT NULL,
      PRIMARY KEY  (playerID),
      UNIQUE KEY playerID (playerID)
    ) TYPE=MyISAM;
    # --------------------------------------------------------
     
    #
    # TABLE STRUCTURE FOR TABLE `playersinseason`
    #
     
    CREATE TABLE playersinseason (
      playerID mediumint(5) NOT NULL DEFAULT '0',
      seasonID mediumint(5) NOT NULL DEFAULT '0',
      KEY playerID (playerID),
      KEY seasonID (seasonID)
    ) TYPE=MyISAM;
    # --------------------------------------------------------
     
    #
    # TABLE STRUCTURE FOR TABLE `season`
    #
     
    CREATE TABLE season (
      seasonID mediumint(5) NOT NULL AUTO_INCREMENT,
      name VARCHAR(40) DEFAULT NULL,
      PRIMARY KEY  (seasonID),
      UNIQUE KEY seasonID (seasonID)
    ) TYPE=MyISAM;

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    remove all lines for UNIQUE keys which specify the same column (in parentheses) as the PRIMARY KEY, then run it again

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it, and yes the error in mysql disappears...
    but i still cant get any values in the tables thru the php-script... so i guess this is a php-problem and not a sql-one

    i will post this problem on the PHP topics

  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script not adding values in to a table

    I found a pretty old php-script to keep track of the stats of my baseball team. But i have a problem getting it to work.
    I did everything that was in the helpfile (install).
    At first there was a problem with the supplied sql-file.
    It is solved but not in the attached files (which is the original one i found on the net)
    I tried to post the link to the thread of the sql-problem here, but i don't seem to have enough posts to do that.

    The problem that remains is that are no values added to the tables and trying to add a season results in a blank page, and adding anything other (e.g. players) results in a simple "error"

    I would really appriciate it if someone could take a look at it, since the website of the creator seems to be down or not existing anymore.
    Attached Files Attached Files

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Maybe you should consider looking for a script that's still actively supported, or into hiring someone to set something up for you? Asking strangers to go through this entire archive to figure out why it doesn't work is a bit much.

    But such generous people do exist, maybe they'll help

    I suspect this script, from 2003, expects register_globals to be enabled, which most hosts don't do anymore for security reasons. The add_player.php code uses some variables that aren't set anywhere, that's probably where they'd come from. You might need to try to override that with a .htaccess file.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •