Mysql query is succesfully executed but doesnt appear in the table
#1

Hello, i have some weird things going on with my register system, when i register it sends a query to the database but it never appears into the database. Also the weird thing is that it always worked and now it has exactly 100 entries in the database and it does not let anyone register anymore. That is kind of weird. This is the log of the mysql:
Код:
[19:09:28] [DEBUG] mysql_pquery - connection: 1, query: "INSERT INTO Users (Name,Password, Admin) VALUES ('K1ll3rw0rm2','", callback: "(null)", format: "(null)"
[19:09:28] [DEBUG] mysql_pquery - connection: 1, query: "UPDATE Users SET IP = '******' WHERE Name='K1ll3rw0rm2'", callback: "(null)", format: "(null)"
[19:09:28] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[19:09:28] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[19:09:28] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 1.631 milliseconds
[19:09:28] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'Money' doesn't have a default value
[19:09:28] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
This is the register dialog:

pawn Код:
Dialog_Register(playerid, response, inputtext[])
{
    switch(response)
    {
        case 1:
        {
            new escpass[100];
            mysql_real_escape_string(inputtext, escpass);
            if(AccountExists[playerid])
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already registered!");

            if(APlayerData[playerid][PlayerLogged] == 1)
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already logged in!");

            if(strlen(inputtext) < 3 || strlen(inputtext) >= 32)
            {
                SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your password is too short or too long!");
                ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "Welcome to European Trucking", "Welcome to European Trucking please register in order to play", "Register", "Cancel");
            }
            CheckMySQL();
            new string[500], buf[129];
            WP_Hash(buf, 129, escpass);
            format(string, sizeof(string), "INSERT INTO Users (Name,Password, Admin) VALUES ('%s','%s', '0')", APlayerData[playerid][Name], buf);
            mysql_pquery( Handle, string, "", "" );

            AccountExists[playerid] = 1;
            SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your account has been created, please login now!");

            ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "Welcome to European Trucking", "Welcome to European Trucking please login in order to play", "Login", "Cancel");

            new string1[128], IP[16], pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            GetPlayerIp(playerid, IP, sizeof(IP));
            format(string1, sizeof(string1), "UPDATE Users SET IP = '%s' WHERE Name='%s'", IP, pName);
            mysql_pquery( Handle, string1, "", "" );
            SendClientMessage(playerid, 0xFF0000, "You have been given 5.000$ starter money");
            GivePlayerCash(playerid, 5000);
            SavePlayer(playerid);
        }
        case 0:
        {
            Kick(playerid);
        }
    }
    return 1;
}
But when it executes, it seems like it succesfully executes but it doesnt actually appear in the database and i cant login onto the server. Anyone an idea why this doesnt work?
Reply
#2

Try to look at old code and compare
Reply
#3

This log:
Код:
[20:08:12] [DEBUG] mysql_pquery - connection: 1, query: "INSERT INTO Users (Name, Password) VALUES ('K1ll3rw0rm2', '292CB", callback: "(null)", format: "(null)"
Is not the whole query? or is it cut off because of the logging thing or is it just querying the query in the debug message? Because its cut off at the password part. Why does it do that because the string is 500 characters long
Reply
#4

Quote:

(error #1364) Field 'Money' doesn't have a default value

This isn't my definition of "successfully executed".
Reply
#5

You're right. But why did that work before? I now have this and it works but now i got zero's where i dont want anything in the database.
pawn Код:
Dialog_Register(playerid, response, inputtext[])
{
    switch(response)
    {
        case 1:
        {
            new escpass[100];
            mysql_real_escape_string(inputtext, escpass);
            print (escpass);
            if(AccountExists[playerid])
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already registered!");

            if(APlayerData[playerid][PlayerLogged] == 1)
                return SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] You're already logged in!");

            if(strlen(inputtext) < 3 || strlen(inputtext) >= 32)
            {
                SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your password is too short or too long!");
                ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "Welcome to European Trucking", "Welcome to European Trucking please register in order to play", "Register", "Cancel");
            }
            CheckMySQL();
            new string2[500], buf[129];
            WP_Hash(buf, 129, escpass);
            format(string2, 500, "INSERT INTO Users (Name, Password, Admin, Money, Score, Fines, Muted, ECoins, MLevel, IP, LastIP, Houses, Club, PJobs, TJobs, CJobs, CoJob, PFed, JJObs, Kmdriven, signature) VALUES ('%s', '%s', 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ' ')", APlayerData[playerid][Name], buf);
            mysql_pquery( Handle, string2, "", "" );
            print(string2);
            AccountExists[playerid] = 1;
            SendClientMessage(playerid, 0xFF0000, "[ACCOUNT] Your account has been created, please login now!");

            ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "Welcome to European Trucking", "Welcome to European Trucking please login in order to play", "Login", "Cancel");

            new string1[128], IP[16], pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            GetPlayerIp(playerid, IP, sizeof(IP));
            format(string1, sizeof(string1), "UPDATE Users SET IP = '%s' WHERE Name='%s'", IP, pName);
            mysql_pquery( Handle, string1, "", "" );
            SendClientMessage(playerid, 0xFF0000, "You have been given 5.000$ starter money");
            GivePlayerCash(playerid, 5000);
            SavePlayer(playerid);
        }
        case 0:
        {
            Kick(playerid);
        }
    }
    return 1;
}
Again, why did the thing work before where i just had name and password?
Reply
#6

Did you (or someone else) modify your tables?
Might be worth checking if those "default" values of 0 have their default value deleted, that might explain why you get that error that money doesn't have a default value.
Reply
#7

I have it fixed but theres something that annoys me. for some rows i dont want anything to be in there, just an empty thing. but now it places NULL in there. How to have a default for it but not let it put anything in?
By the way this is the structure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)