SQL Not reading the account in the database
#1

So I started developing an SQL Based Gamemode and I'm having an issue. I almost finished the registration part so I decided to hit up then login system but apperently it does not read or create the account in the Database.

My Codes

OnPlayerConnect
pawn Код:
if(IsARolePlayName(szName)) {
        FillingPassportDetails[playerid] = false;
        GetPlayerName(playerid, szName, sizeof(szName));
        format(szQuery, sizeof(szQuery), "SELECT `NAME` FROM `ACCOUNTS` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(szName));
        Result = db_query(Database, szQuery);
        if(db_num_rows(Result)) {
            SendClientMessage(playerid, -1, "REGISTERED"); // Checking if the account is registered
        }
        else {
            new szCName[128], szString[128];
            GetPlayerName(playerid, szCName, 128);
            SetSpawnInfo( playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            SpawnPlayer(playerid);

            format(szString, sizeof(szString), ""COLOR_WHITE"Welcome "COLOR_LIGHTBLUE"%s"COLOR_WHITE",\nSelect your account password.", szCName);
            db_query(Database, szQuery);
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Chrome Roleplay", szString, "Validate", "");
        }
        db_free_result(Result);
    }
OnDialogResponse
pawn Код:
case DIALOG_REGISTER: {
            if(!response) Kick(playerid);
           
            if(response) {
                if(strlen(inputtext) < 4 || strlen(inputtext) > 24) {
                        new szString[128];
                        format(szString, sizeof(szString), ""COLOR_RED"Error: Password must be between 4 and 24 characters.\n"COLOR_WHITE"Welcome "COLOR_LIGHTBLUE"%s"COLOR_WHITE",\nSelect your account password.", szName);
                        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "", szString, "Validate", "");
                }
               
                else {
                    new sCzName[128];
                    GetPlayerName(playerid, sCzName, sizeof(sCzName));
                    format(szQuery, sizeof(szQuery), "INSERT INTO `ACCOUNTS` (`NAME`, `PASSWORD`, `MONEY`, `FACTION`, `LEVEL`, `ADMINLEVEL`, `HELPER`, `MODERATOR`, `DONATOR`, `FRANK`) VALUES('%s', '%s', '4000', '-1', '0', '0', '0', '0', '0', '0')", DB_Escape(sCzName), DB_Escape(inputtext));
                    db_query(Database, szQuery);
Please note that the above part is a part of the DialogResponse and contains the necessary scripts to save the data in the Database ( I didn't include the whole script since other parts were unneccesary )

Thanks.
Reply
#2

numeric values are not written in '...
Код:
'%s', '%s', 4000, -1, 0, 0, etc.
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
numeric values are not written in '...
Код:
'%s', '%s', 4000, -1, 0, 0, etc.
Fixed that but apparently that was not the problem. Anyone has any idea on how to fix this ?
Reply
#4

So uhm perhaps, is there a way to print/view an SQL Log when it attempts to create a table, insert values etc so I can find if any issues or errors are visible?
Reply
#5

Check your mysql_log.txt in server folder. Also, if you want to insert using all fields except id, you don't have to list them all. You can do something like
Quote:

INSERT INTO `ACCOUNTS` VALUES(null, '%s', '%s', '4000', '-1', '0', '0', '0', '0', '0', '0')

#e: Oh, it's SQLite, sorry, that log won't help
Reply
#6

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Check your mysql_log.txt in server folder. Also, if you want to insert using all fields except id, you don't have to list them all. You can do something like
I just checked the mysql log but it does only print the startup message

Код:
[Sun Aug 18 16:40:53 2013] -------------------------
[Sun Aug 18 16:40:53 2013]      Logging Started
[Sun Aug 18 16:40:53 2013] -------------------------
and tried aswell to change that to null but didn't had any luck :/
Reply
#7

I can tell you that mysql log has nothing to do with SQLite. But I won't be helping any further unless you educate yourself on password hashing.
Reply
#8

Quote:
Originally Posted by Stylock
Посмотреть сообщение
I can tell you that mysql log has nothing to do with SQLite. But I won't be helping any further unless you educate yourself on password hashing.
Password hashing has nothing to do with this issue. Even with a hashed password I would still get this issue since it is not the password the one which is causing the problem. It just doesn't create the player's table with his name.

EDIT: Solved. After trying to print the query I realised that the query's size is not big enough for the whole statement ant was causing it to not complete the full command but now it's working fine. Thanks anyways for replies
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)