Help me for MySQL query error !
#1

Help me for this.


Quote:

[23:31:07] [DEBUG] mysql_format - connection: 1, len: 1000, format: "INSERT INTO `players`(`Username`,`Password`,`IP`, `Admin`,`VIP`,`Money`,`Cash` ,`TotalScore`,`DriftScore`, `DuelScore`,`Groupid`..."
[23:31:07] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `players`(`Username`,`Password`,`IP`, `Admin`,`VIP`,", callback: "OnAccountRegister", format: "i"
[23:31:07] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - starting query execution
[23:31:07] [ERROR] CMySQLQuery::Execute[OnAccountRegister] - (error #1136) Column count doesn't match value count at row 1
[23:31:07] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - error will be triggered in OnQueryError
[23:31:07] [DEBUG] Calling callback "OnQueryError"..

Reply
#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
#3

Change this...
pawn Код:
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]);
//to this
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]);
The spot that was causing you issues was

pawn Код:
`players'
//it needs to be
`players`
You had ' instead of ` (Cant thing of what they are called atm....)
Reply
#4

omg my mistake.
thanks +rep
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)