SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    0 Post(s)
    0 Thread(s)

    MySQL table problem

    # Table structure for table `config`

    CREATE TABLE config (
    idthg int(11) NOT NULL auto_increment,
    user varchar(25) NOT NULL default '',
    pass varchar(255) NOT NULL default '',
    admin int(1) NOT NULL default '0',
    email varchar(255) NOT NULL default '',
    no_of_ref int(2) NOT NULL default '0',
    rate_user int(2) NOT NULL default '0',
    ref_earn int(3) NOT NULL default '0',
    no_sites int(2) NOT NULL default '0',
    credits float NOT NULL default '0',
    data_start date NOT NULL default '0000-00-00',
    credit_start tinyint(1) NOT NULL default '0',
    timer tinyint(3) NOT NULL default '0',
    referrals varchar(255) NOT NULL default '',
    rate_admin int(3) NOT NULL default '0',
    idthq tinyint(1) NOT NULL default '0',
    days_no int(11) NOT NULL default '0',
    tampon_url varchar(255) NOT NULL default '',
    tampon_name varchar(255) NOT NULL default '',
    credit float NOT NULL default '0',
    hits float NOT NULL default '0',
    initial_bonus int(11) NOT NULL default '0',
    contest_bonus int(11) NOT NULL default '0',
    contest_views int(11) NOT NULL default '0',
    PRIMARY KEY (idthg)
    ) TYPE=MyISAM;

    # Dumping data for table `config`

    INSERT INTO config VALUES (1, 'admin', 'admin', 1, '', 5, 50, 25, 5, '13819.2', '2003-01-11', 100, 20, '10;7;5;2;1', 25, 1, 0, '', 'Yigle Traffic Exchange', '0', '0', 100, 10, 100);
    # --------------------------------------------------------

    This is the MySQL I need to put in tables, I filled in the content in the PHPMyAdmin and it keeps on saying this error "Incorrect table definition; There can only be one auto column and it must be defined as a key". Can you help me with my dilema ? Can you also tell me what do I put in Table Comments ?


  2. #2
    Join Date
    Jan 2003
    0 Post(s)
    0 Thread(s)
    Umm... Nothing wrong with the PK that I can see; you have 24 fields and in your INSERT all 24 are there as well; although when you are using VALUE you first need to give which fields you are inserting, followed by their values...

    PHP Code:
    INSERT INTO config (..fields..) VALUES (..values..); 
    This method allows you to insert data into a table in any order and also means that you do not need to insert all the data; ie you could just as well only want to insert into 3 fields ?

    An alternative is to use SET ? Although in this case you do need to insert in the right order of fields, ie

    PHP Code:
    INSERT INTO config SET
    "Dr Livingstone",
    Note: In your email field, you give 255 characters ? Doubtful if you'll see an email address that long, so cut it back to maybe 95 ? Reason being, in another post I read, to avoid sql injection attacks, the least number of characters allowed reduces what someone can attempt to use against your database in regards to the amount of text available...

    Hope this helps, as I really cannot see what it is with your PK; it all looks good from here.


Posting Permissions

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