Duplicate Key!
#1

ERROR MYSQL:
Код HTML:
EndCB();Log("11:41:48","CMySQLQuery::Execute[OnVehInsert]",1,"(error #1062) Duplicate entry '1' for key 'PRIMARY'",1);
Код HTML:
CREATE TABLE IF NOT EXISTS `vehicles` (
  `ID` int(11) NOT NULL,
  `Owner` int(11) NOT NULL,
  `Model` int(6) NOT NULL,
  `PosX` float NOT NULL,
  `PosY` float NOT NULL,
  `PosZ` float NOT NULL,
  `VAngle` float NOT NULL,
  `ServerID` int(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Код HTML:
ALTER TABLE `vehicles`
  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
Reply
#2

Try this:

Код:
CREATE TABLE IF NOT EXISTS `vehicles` (
  `ID` int(11) AUTO_INCREMENT,
  `Owner` int(11) NOT NULL,
  `Model` int(6) NOT NULL,
  `PosX` float NOT NULL,
  `PosY` float NOT NULL,
  `PosZ` float NOT NULL,
  `VAngle` float NOT NULL,
  `ServerID` int(6) NOT NULL,
   PRIMARY KEY(`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The other part should not be needed.
Reply
#3

MYSQL ERROR:
Код HTML:
--
-- Indexes for table `vehicles`
--
ALTER TABLE `vehicles`
  ADD PRIMARY KEY (`ID`);
#1068 - Multiple primary key defined
Reply
#4

Код:
CREATE TABLE IF NOT EXISTS `vehicles` (
  `ID` int(11) AUTO_INCREMENT,
  `Owner` int(11) NOT NULL,
  `Model` int(6) NOT NULL,
  `PosX` float NOT NULL,
  `PosY` float NOT NULL,
  `PosZ` float NOT NULL,
  `VAngle` float NOT NULL,
  `ServerID` int(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Go for this one then and let me know what is your current PRIMARY KEY.
Reply
#5

DataBase SQL:
Код HTML:
--
-- Indexes for table `vehicles`
--
ALTER TABLE `vehicles`
  ADD PRIMARY KEY (`ID`);
Код HTML:
--
-- AUTO_INCREMENT for table `vehicles`
--
ALTER TABLE `vehicles`
  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
Reply
#6

Just delete the current database and use this and don't alter the table anymore is not needed.

Код:
CREATE TABLE IF NOT EXISTS `vehicles` (
  `ID` int(11) AUTO_INCREMENT,
  `Owner` int(11) NOT NULL,
  `Model` int(6) NOT NULL,
  `PosX` float NOT NULL,
  `PosY` float NOT NULL,
  `PosZ` float NOT NULL,
  `VAngle` float NOT NULL,
  `ServerID` int(6) NOT NULL,
   PRIMARY KEY(`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Or you can put this lines on your gm.
Reply
#7

Don't work!
Код HTML:
EndCB();Log("12:24:27","CMySQLQuery::Execute[OnVehInsert]",1,"(error #1062) Duplicate entry '1' for key 'PRIMARY'",1);
Reply
#8

Show me the code(the insert query that is generating this error).I guess is "OnVehInsert".
Reply
#9

Is your ID column set to auto_increment?
Reply
#10

Rappy@: Yes

Aly:
Код HTML:
stock OnVehInsert(r, playerid)
{
    new ORM:ormid = Veh[r][ORM_ID] = orm_create("vehicles",MySQLCon);
    orm_addvar_int(ormid, Veh[r][ID], "ID"); //this is the key
    orm_addvar_int(ormid, Veh[r][Owner], "Owner");
    orm_addvar_int(ormid, Veh[r][Model], "Model");
    orm_addvar_float(ormid, Veh[r][PosX], "PosX");
    orm_addvar_float(ormid, Veh[r][PosY], "PosY");
    orm_addvar_float(ormid, Veh[r][PosZ], "PosZ");
    orm_addvar_float(ormid, Veh[r][VAngle], "VAngle");
    orm_addvar_int(ormid, Veh[r][ServerID], "ServerID");
    orm_setkey(ormid,"ID");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)