SQLite - Insert INTO ... not working
#8

Quote:
Originally Posted by Jefff
View Post
pawn Code:
stock CreateFaction(ownerid, const name[])
{
    new Query[128];
    format(Query, sizeof(Query), "INSERT INTO `FACTIONS` (`NAME`, `LEADER`) VALUES ('%s', '%s')", DB_Escape(name), DB_Escape(GetName(ownerid)));
    db_query(Factions, Query);
    SendClientMessage(ownerid, -1, "{64CC66}Faction successfully created!");
    SendClientMessage(ownerid, -1, "{64CC66}You can use '/settings' to edit the faction info!");
}

pawn Code:
CMD:createfaction(playerid, params[])
{
    if(PlayerInfo[playerid][fID]) SendClientMessage(playerid, -1, "{FC4949}You're already in a faction!");
    else if(isnull(params)) SendClientMessage(playerid, COLOR_NOTES, "You must enter a faction-name!");
    else if(strlen(params) > 59) SendClientMessage(playerid, COLOR_NOTES, "Faction-name is too long!");
    else CreateFaction(playerid, params);
    return 1;
}
OnGameModeInit
pawn Code:
new str[525 char];
    str = !"CREATE TABLE IF NOT EXISTS `FACTIONS` (\
        `ID` INTEGER NOT NULL PRIMARY KEY,\
        `NAME` VARCHAR(64),\
        `LOCKED` SMALLINT(1) NOT NULL DEFAULT 1,\
        `ACTIVE` SMALLINT(1) NOT NULL DEFAULT 1,\
        `MAXMEMBERS` SMALLINT(2) NOT NULL DEFAULT 10,\
        `MEMBERS` SMALLINT(2) NOT NULL DEFAULT 1,"

    ;
    strcat(str,!"`LEADER` VARCHAR(25),\
        `HASLEADER` SMALLINT(1) NOT NULL DEFAULT 1,\
        `RANK1` VARCHAR(15) DEFAULT 'Trial Member',\
        `RANK2` VARCHAR(15) DEFAULT 'Member',\
        `RANK3` VARCHAR(15) DEFAULT 'Senior Member',\
        `RANK4` VARCHAR(15) DEFAULT 'Assistant',\
        `RANK5` VARCHAR(15) DEFAULT 'Leader')"
);

    db_query(Factions, str);
Due to the 'const name[]' i get
Code:
error 035: argument type mismatch (argument 1)
at line;
pawn Code:
format(Query, sizeof(Query), "INSERT INTO `FACTIONS` (`NAME`, `LEADER`) VALUES ('%s', '%s')", DB_Escape(name), DB_Escape(GetName(ownerid)));
Should I just remove the const?
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: 1 Guest(s)