Convert to MySQL (sqlite_escape_string)
#1

pawn Код:
case DIALOG_MAIN_MENU_CHARACTER_DELETE:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1)
                {
                    if(CharacterExists(sqlite_escape_string(InsertPlayerUnderscoreString(inputtext))))
                    {
                        if(PlayerOwnsCharacter_Name(playerid, sqlite_escape_string(InsertPlayerUnderscoreString(inputtext))))
                        {
                            format(query, sizeof(query), "DELETE FROM `Character` WHERE `name` = '%s'", sqlite_escape_string(InsertPlayerUnderscoreString(inputtext)));
                            db_free_result(db_query(database,query));
                            format(query, sizeof(query), "[I:] You have successfully deleted character: %s.", inputtext);
                            SendClientMessage(playerid, COLOR_YELLOW, query);
                            ShowMenuDialog(playerid);
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                        }
                    }
                    else
                    {
                         ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                }
                else
                {
                     ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }

pawn Код:
sqlite_escape_string
What would I use instead?
Reply
#2

Click on meeh!
Reply
#3

I still don't get it..
Reply
#4

Read the wiki and try to do it by yourself, I still don't get why people script without learning, Don't wait for ready script mate !
Reply
#5

I tried it.. Hence "Still don't get it"
Reply
#6

Try this:
pawn Код:
new escapedstring[50];
                        mysql_real_escape_string(InsertPlayerUnderscoreString(inputtext), escapedstring);
                        if(PlayerOwnsCharacter_Name(playerid, escapedstring))
Reply
#7

pawn Код:
case DIALOG_MAIN_MENU_CHARACTER_DELETE:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1)
                {
                    if(CharacterExists(mysql_real_escape_string(inputtext, InsertPlayerUnderscoreString)))
                    {
                        new escapedstring[50];
                        mysql_real_escape_string(InsertPlayerUnderscoreString(inputtext), escapedstring);
                        if(PlayerOwnsCharacter_Name(playerid, escapedstring));
                        {
                            new query[128];
                            format(query, sizeof(query), "DELETE FROM `Character` WHERE `cName` = '%s'", inputtext); //(InsertPlayerUnderscoreString(inputtext)
                           
                            format(query, sizeof(query), "[I:] You have successfully deleted character: %s.", inputtext);
                            SendClientMessage(playerid, COLOR_YELLOW, query);
                            ShowMenuDialog(playerid);
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                        }
                    }
                    else
                    {
                         ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                }
                else
                {
                     ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
I can't see the problem..

pawn Код:
MyProject.pwn(2433) : error 076: syntax error in the expression, or invalid function call
MyProject.pwn(2437) : error 036: empty statement
pawn Код:
f(CharacterExists(mysql_real_escape_string(inputtext, InsertPlayerUnderscoreString))) // 2433
if(PlayerOwnsCharacter_Name(playerid, escapedstring)); //2437
Reply
#8

Can anyone help?
Reply


Forum Jump:


Users browsing this thread: