Zoe Skandinavia
Member
- Joined
- Jul 18, 2014
- Messages
- 193
- Solutions
- 2
- Reaction score
- 15
Hello!, i always got this error, when i create a guild, it says at the end: Guild with ID 0 doesn't exist.
I tried with some things. If i delete "guilds" table from database and put it again by SQL:
this message doesn't appear anymore, but in guild there's no members:
At the beginning, i thought it happens because i didn't add the Trigger yet:
but when i add it, the message: "Guild with ID: 0 doesn't exist." appears again, so i think this is the reason, but i don't know how to fix it.
This is my guilds.php:
I put only the part where it creates the guild.
I hope you can help me.
Thanks.
I tried with some things. If i delete "guilds" table from database and put it again by SQL:
Code:
CREATE TABLE IF NOT EXISTS `guilds` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`ownerid` int(11) NOT NULL,
`creationdata` int(11) NOT NULL,
`motd` varchar(255) NOT NULL DEFAULT '',
`description` text NOT NULL,
`guild_logo` mediumblob,
`create_ip` int(11) NOT NULL DEFAULT '0',
`balance` bigint(20) unsigned NOT NULL DEFAULT '0',
`last_execute_points` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `ownerid` (`ownerid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
At the beginning, i thought it happens because i didn't add the Trigger yet:
Code:
DROP TRIGGER IF EXISTS `oncreate_guilds`;
DELIMITER //
CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds`
FOR EACH ROW BEGIN
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`);
INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`);
END
//
DELIMITER ;
This is my guilds.php:
PHP:
if($todo == 'save')
{
$new_guild = new Guild();
$new_guild->setCreationData(time());
$new_guild->setName($new_guild_name);
$new_guild->setOwner($player);
$new_guild->setDescription('New guild. Leader must edit this text :)');
$new_guild->setGuildLogo('image/gif', Website::getFileContents('./images/default_guild_logo.gif'));
$new_guild->save();
$ranks = $new_guild->getGuildRanksList(true);
foreach($ranks as $rank)
if($rank->getLevel() == 3)
{
$player->setRank($rank);
$player->save();
}
$main_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white><B>Create guild</B></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD WIDTH=100%><b>Congratulations!</b><br/>You have created guild <b>'.htmlspecialchars($new_guild_name).'</b>. <b>'.htmlspecialchars($player->getName()).'</b> is leader of this guild. Now you can invite players, change picture, description and motd of guild. Press submit to open guild manager.</TD></TR></TABLE><br/><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><FORM ACTION="?subtopic=guilds&action=show&guild='.$new_guild->getId().'" METHOD=post><TR><TD><center><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></TD></TR></FORM></TABLE>';
}
I put only the part where it creates the guild.
I hope you can help me.
Thanks.