phence Posted November 28, 2003 Share Posted November 28, 2003 I can\'t figure this out??? I have one result in this db, and when i try to add any more i get an error saying \"Duplicate Key at Query Line 1\" CREATE TABLE attendees ( id int(6) auto-increment NOT NULL, regtime datetime DEFAULT \'0000-00-00 00:00:00\' NOT NULL, host varchar(255) NOT NULL, ip varchar(15) NOT NULL, eventid varchar(9) NOT NULL, age date DEFAULT \'0000-00-00\' NOT NULL, terms varchar(5) NOT NULL, firstname tinytext NOT NULL, lastname tinytext NOT NULL, clanname varchar(255), alias varchar(255) NOT NULL, address1 tinytext NOT NULL, address2 tinytext, city tinytext NOT NULL, state char(3) NOT NULL, zip varchar(5) NOT NULL, country tinytext NOT NULL, hphone varchar(20) NOT NULL, wphone varchar(20), cphone varchar(20), IMcontact varchar(50), email varchar(255) NOT NULL, arrival char(3) NOT NULL, airline char(2) NOT NULL, party varchar(4) NOT NULL, hotel text NOT NULL, seat char(3) NOT NULL, clanid int(11) DEFAULT \'0\' NOT NULL, code varchar(10) NOT NULL, PRIMARY KEY (regtime), UNIQUE seat (seat), KEY regtime (regtime) ); $sql = mysql_query(\"INSERT INTO attendees (id, regtime, host, ip, eventid, age, terms, firstname, lastname, clanname, alias, address1, address2, city, state, zip, country, hphone, wphone, cphone, IMcontact, email, arrival, airline, party, hotel, seat, clanid, code) VALUES (\'0\', now(), \'\" . $host . \"\', \'\" . $ip . \"\', \'\" . $_SESSION[\'eventid\'] . \"\', \'\" . $dob . \"\', \'\" . $_SESSION[\'terms\'] . \"\', \'\" . $usrVars[\'firstname\'] . \"\', \'\" . $usrVars[\'lastname\'] . \"\', \'\" . $clanname . \"\', \'\" . $usrVars[\'alias\'] . \"\', \'\" . $usrVars[\'address1\'] . \"\', \'\" . $usrVars[\'address2\']. \"\', \'\" . $usrVars[\'city\'] . \"\', \'\" . $usrVars[\'state\'] .\"\', \'\" . $usrVars[\'zip\'] . \"\', \'\" . $usrVars[\'country\'] . \"\', \'\" . $usrVars[\'hphone\'] . \"\', \'\" . $usrVars[\'wphone\'] . \"\', \'\" . $usrVars[\'cphone\'] . \"\', \'\" . $usrVars[\'IMcontact\'] . \"\', \'\" . $_SESSION[\'email\'] . \"\', \'\" . $usrVars[\'arrival\'] . \"\', \'\" . $usrVars[\'airline\'] . \"\', \'\" . $usrVars[\'party\'] . \"\' , \'\" . $usrVars[\'hotel\'] . \"\', \'\" . $seat . \"\', \'\" . $clanid . \"\', \'\" . $code . \"\')\") or die (mysql_error()); please help i need this to work in the next couple hours!! aahhhh Thanks so much Quote Link to comment Share on other sites More sharing options...
metalblend Posted November 28, 2003 Share Posted November 28, 2003 ..read the error message: duplicate key A primary|index key\'d column cannot have duplicate entries, meaning that if you\'ve used a 0 for your id column, 0 cannot be inserted again. If this is an auto_increment\'ing column, you don\'t even need to set the id column, as MySQL will insert the next value automatically. Use a different value for id each time you insert into the database. Hope that helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.