SQLite - Insert INTO ... not working
#1

So, I've been struggling with this command/stock for quite a time now, and each time i try to fix it, it just still fails to create.

Stuff;
pawn Code:
enum e_FactionInfo
{
    fID, //factionID
    fName[60], //faction Name
    Locked, Active, //Lock Mode(invite), Active
    MaxMembers, Members, Leader, HasLeader, //Max-Members, current members and leader.
    Ranks[5]
}
//Onfilterscriptinit
db_query(Factions, "CREATE TABLE IF NOT EXISTS `FACTIONS` (`ID`, `NAME`, `LOCKED`, `ACTIVE`, `MAXMEMBERS`, `MEMBERS`, `LEADER`, `RANK1`, `RANK2`, `RANK3`, `RANK4`, `RANK5`)");
//creating faction
CMD:createfaction(playerid, params[]) {
    if(PlayerInfo[playerid][fID]) return SendClientMessage(playerid, -1, "{FC4949}You're already in a faction!");
    new factionname[60];
    if(sscanf(params, "s[60]", factionname)) return SendClientMessage(playerid, COLOR_NOTES, "You must enter a faction-name!");

    CreateFaction(playerid, factionname);
    return 1;
}
stock CreateFaction(ownerid, name[])
{
    new DBResult:result, Query[360];
    new DBResult:count = db_query(Factions, "SELECT * FROM `FACTIONS`");
    if(db_num_rows(count)) format(Query, sizeof(Query), "INSERT INTO `FACTIONS` (`ID`, `NAME`, `LOCKED`, `ACTIVE`, `MAXMEMBERS`, `MEMBERS`, `LEADER`, `HASLEADER`, `RANK1`, `RANK2`, `RANK3`, `RANK4`, `RANK5`) VALUES ('%d', '%s', '1', '1', '10', '1', '%s', '1', 'Trial Member', 'Member', 'Senior Member', 'Assistant', 'Leader')", db_num_rows(count)+1, DB_Escape(name), DB_Escape(GetName(ownerid)));
    else if(!db_num_rows(count)) format(Query, sizeof(Query), "INSERT INTO `FACTIONS` (`ID`, `NAME`, `LOCKED`, `ACTIVE`, `MAXMEMBERS`, `MEMBERS`, `LEADER`, `HASLEADER`, `RANK1`, `RANK2`, `RANK3`, `RANK4`, `RANK5`) VALUES ('1', '%s', '1', '1', '10', '1', '%s', '1', 'Trial Member', 'Member', 'Senior Member', 'Assistant', 'Leader')", DB_Escape(name), DB_Escape(GetName(ownerid)));
    result = db_query(Factions, Query);
    if(result) SendClientMessage(ownerid, -1, "{64CC66}Faction successfully created!"), SendClientMessage(ownerid, -1, "{64CC66}You can use '/settings' to edit the faction info!");
    else SendClientMessage(ownerid, -1, "{FC4949}Failed to create faction, contact server owner(s).");
    db_free_result(result);
}
What could be wrong here? D:
Reply


Messages In This Thread
SQLite - Insert INTO ... not working - by Kyance - 17.09.2014, 15:41
Re: SQLite - Insert INTO ... not working - by SKAzini - 17.09.2014, 16:02
Re: SQLite - Insert INTO ... not working - by KayJ - 17.09.2014, 16:03
Re: SQLite - Insert INTO ... not working - by Kyance - 17.09.2014, 16:21
Re: SQLite - Insert INTO ... not working - by Pottus - 17.09.2014, 16:25
Re: SQLite - Insert INTO ... not working - by Kyance - 17.09.2014, 16:31
Re: SQLite - Insert INTO ... not working - by Jefff - 17.09.2014, 16:33
Re: SQLite - Insert INTO ... not working - by Kyance - 17.09.2014, 16:37
Re: SQLite - Insert INTO ... not working - by Jefff - 17.09.2014, 16:37
Re: SQLite - Insert INTO ... not working - by Kyance - 17.09.2014, 16:39

Forum Jump:


Users browsing this thread: 2 Guest(s)