mysql help please
#1

Код:
[22:39:37] [ERROR] CMySQLQuery::Execute[OnAccountLoad(i)] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''players' WHERE 'Username' = 'RaiD' LIMIT 1' at line 1
[22:39:43] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''players' SET 'Admin' = 67, 'VIP' = 67, 'Money' = 48 WHERE 'ID' = 49' at line 1
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case d_login:
        {
            if(!response) return Kick(playerid);

            new hpass[129];
            new Query[100];
            WP_Hash(hpass, 129, inputtext);
            if(!strcmp(hpass, PlayerInfo[playerid][Password]))
            {
                mysql_format(mysql, Query, sizeof(Query),"SELECT * FROM 'players' WHERE 'Username' = '%e' LIMIT 1", Name[playerid]);
                mysql_tquery(mysql, Query, "OnAccountLoad", "i", playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, d_login, DIALOG_STYLE_INPUT, "Login", "Kindly Login to Proceed", "Login", "Quit");
            }
        }
        case d_register:
        {
            if(!response) return Kick(playerid);
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, d_register, DIALOG_STYLE_INPUT, "Register", "{FF0000}Your password must be at least 6 characters long.", "Register", "Quit");

            new Query[300];
            WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
            mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`) VALUES ('%e', '%s', '%s', 0, 0, 0)", Name[playerid], PlayerInfo[playerid][Password], IP[playerid]);
            mysql_tquery(mysql, Query, "OnAccountRegister", "i", playerid);
        }
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new Query[128];
   
    mysql_format(mysql, Query, sizeof(Query), "UPDATE 'players' SET 'Admin' = %d, 'VIP' = %d, 'Money' = %d WHERE 'ID' = %d",
    PlayerInfo[playerid][Admin],
    PlayerInfo[playerid][VIP],
    PlayerInfo[playerid][Money],
    PlayerInfo[playerid][ID]
    );
   
    mysql_tquery(mysql, Query, "", "");
   
    return 1;
}
pawn Код:
forward OnAccountLoad(playerid);
forward OnAccountRegister(playerid);

public OnAccountLoad(playerid)
{
    PlayerInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
    PlayerInfo[playerid][VIP] = cache_get_field_content_int(0, "VIP");
    PlayerInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
   
    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
    SendClientMessage(playerid, -1, "Successfully Logged In. Welcome Back to the Server!");
    return 1;
}

public OnAccountRegister(playerid)
{
    PlayerInfo[playerid][ID] = cache_insert_id();
    printf("New Account Registered. ID: %d", PlayerInfo[playerid][ID]);
    return 1;
}
using r33 plugin. Followed this tutorial: https://sampforum.blast.hk/showthread.php?tid=485633
Reply
#2

You sql-syntax is wrong.

Код:
SELECT * FROM 'players' WHERE 'Username' = '%e' LIMIT 1;
should be:
Код:
SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1;
And:
Код:
UPDATE 'players' SET 'Admin' = %d, 'VIP' = %d, 'Money' = %d WHERE 'ID' = %d;"
should be:
Код:
UPDATE `players` SET `Admin` = '%d', `VIP` = '%d', `Money` = '%d' WHERE `ID` = '%d';"
Reply
#3

thank you bro.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)