30.07.2016, 18:36
Your queries are completly wrong, no use of "," at places, no "`" to enclose columns and so one...
I suggest you to go through a basic syntax tutorial on SQL. Can be found anywhere on ******.
Here is the correct way and you don't need to use a callback for that, because mysql_tquery returns 1 or 0 for success and fail.
I suggest you to go through a basic syntax tutorial on SQL. Can be found anywhere on ******.
Here is the correct way and you don't need to use a callback for that, because mysql_tquery returns 1 or 0 for success and fail.
pawn Код:
case factionnamed:
{
new bool:success = true;
format(Player[playerid[FactionName], 120, inputtext);
new query[200];
mysql_format(mysql, query, sizeof (query), "INSERT INTO `faction` (`factionname`) VALUES ('%e')", inputtext);
if (mysql_tquery(mysql, query) == 0)
success = false;
mysql_format(mysql, query, sizeof (query), "UPDATE `accounts` SET `factionname` = '%e', `factionid` = %d WHERE `ID` = %d LIMIT 1", Player[playerid][FactionName], Faction[playerid][ID], Player[playerid][ID]);
if (mysql_tquery(mysql, query) == 0)
success = false;
if (success)
{
// Every thing went well
ShowPlayerDialog(playerid, factiontyped, DIALOG_STYLE_LIST, "FACTION CREATION", "Type 0(Drugs)\nType 1(Weapons)", "Choose","Cancel");
}
else
{
// Either a new row in "faction" table wasn't created or `accounts` wasn't updated
}
}

