Help me for MySQL query error !
#2

no one ?

This My script :

pawn Код:
public OnPlayerConnect(playerid)
{
    new query[500];
    GetPlayerIp(playerid, IP[playerid], 16);
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", GetName(playerid));
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    return 1;
}

public OnAccountCheck(playerid)
{
    if(cache_num_rows())
    {//then
        cache_get_field_content(0, "Password", pInfo[playerid][Password], mysql, 129);
        pInfo[playerid][ID] = cache_get_field_content_int(0, "ID"); //now let's load player's ID into pInfo[playerid][ID] so we can use it later
        ShowPlayerDialog(playerid, Dialoglogin, DIALOG_STYLE_PASSWORD, "Login", ""WI"In order to play, you need to login :", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
    }
    else //if we didn't find any rows from the database, that means, no accounts were found
    {
        ShowPlayerDialog(playerid, Dialogregister, DIALOG_STYLE_INPUT, "Register", ""WI"In order to play, you need to register :", "Register", "Quit");
        //So we show them a dialog register
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case Dialogregister: //register dialog
        {
            if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, Dialogregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
            pInfo[playerid][Login] = 1;
            new query[500];
            format(pInfo[playerid][Password], 129, inputtext);
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `players' (`Username`,`Password`,`IP`,`Color`) VALUES ('%e', '%s', '%s', -1)",GetName(playerid),pInfo[playerid][Password],IP[playerid]);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
        }
    }
    return 1;
}

public OnAccountRegister(playerid)
{
    pInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("New account registered. ID: %d", pInfo[playerid][ID]); //just for debugging.
    return 1;
}
Help me please
Reply


Messages In This Thread
Help me for MySQL query error ! - by VenomMancer - 13.02.2015, 15:07
Re: Help me for MySQL query error ! - by VenomMancer - 14.02.2015, 00:39
Re: Help me for MySQL query error ! - by nickdodd25 - 14.02.2015, 00:59
Re: Help me for MySQL query error ! - by VenomMancer - 14.02.2015, 04:48

Forum Jump:


Users browsing this thread: 1 Guest(s)