• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Elf warsystem

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Reaction score
5
Location
Halland - Getinge
Players in war get frags!

CREATE TABLE IF NOT EXISTS `guild_wars` (

`id` INT NOT NULL AUTO_INCREMENT,

`guild_id` INT NOT NULL,

`enemy_id` INT NOT NULL,

`begin` BIGINT NOT NULL DEFAULT '0',

`end` BIGINT NOT NULL DEFAULT '0',

`frags` INT UNSIGNED NOT NULL DEFAULT '0',

`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',

`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',

`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',

`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',

PRIMARY KEY (`id`),

KEY `status` (`status`),

KEY `guild_id` (`guild_id`),

KEY `enemy_id` (`enemy_id`)

) ENGINE=InnoDB;



ALTER TABLE `guild_wars`

ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,

ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;



ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;



CREATE TABLE IF NOT EXISTS `guild_kills` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

`guild_id` INT NOT NULL,

`war_id` INT NOT NULL,

`death_id` INT NOT NULL

) ENGINE = InnoDB;



ALTER TABLE `guild_kills`

ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,

ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,

ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;



ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;


Can anyone see the problem?
 
I get a message in console

Code:
mysql_real_query(): INSERT INTO `guild kills` (`guild_id`, `war_id`, `death_id`) VALUES (0,28,3711); -MYSQL ERROR: Cannot add or update a child row: a foreign key constraint fails (`DBNAME`.`guild_kills`, CONSTRAINT `guild:kills_ibfk_1`FOREIGN KEY (`war_id`) REFERENCES `guild_wars`(ìd`) ON DELETE CASCADE) (1452)
 
Basically what i'm getting from the error is that you must've done something wrong when using the sql code since you're trying to add something to a child row which would make it into a row within a row.
 
Back
Top