MySQL R41
#1

Okay so here is the problem. When i enter server it requies password for registering. When i reconnect it is asking for password again. It won't create account..
here is dialogregister and OnPlayerRegister
PHP Code:
case DIALOG_REGISTER:
        {
            if(!
response)
            {
                return 
Kick(playerid);
            }
            if(
strlen(inputtext) <= 5)
            {
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""Your password needs to be longer that 5 characters""Register""Exit");
                return 
1;
            }
            for(new 
016i++)
            {
                
PlayerInfo[playerid][Salt][i] = random(94) + 33;
                
SHA256_PassHash(inputtextPlayerInfo[playerid][Salt], PlayerInfo[playerid][Password], 65);
                new 
query[221];
                
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('%e', '%s', '%e')"PlayerInfo[playerid][Name], PlayerInfo[playerid][Password], PlayerInfo[playerid][Salt]);
                
mysql_tquery(g_SQLquery"OnPlayerRegister""d"playerid);
            }
        }
        default: return 
0;
forward OnPlayerRegister(playerid);
public 
OnPlayerRegister(playerid)
{
    
PlayerInfo[playerid][ID] = cache_insert_id();
    
ShowPlayerDialog(playeridDIALOG_UNUSEDDIALOG_STYLE_MSGBOX"Registration""Account succesfully registered!\nYou have been automaticly logged in""Ok""");
    
PlayerInfo[playerid][IsLoggedIn] = true;
    
PlayerInfo[playerid][X_Pos] = DEFAULT_POS_X;
    
PlayerInfo[playerid][Y_Pos] = DEFAULT_POS_Y;
    
PlayerInfo[playerid][Z_Pos] = DEFAULT_POS_Z;
    
PlayerInfo[playerid][A_Pos] = DEFAULT_POS_A;
    
SetSpawnInfo(playeridNO_TEAM0PlayerInfo[playerid][X_Pos], PlayerInfo[playerid][Y_Pos], PlayerInfo[playerid][Z_Pos], PlayerInfo[playerid][A_Pos], 000000);
    
SpawnPlayer(playerid);
    return 
1;

Reply
#2

I believe that loop is meant to fill the salt ONLY. Get everything else outside that loop immediately.
Reply
#3

You mean like this??
PHP Code:
for(new 016i++)
            {
                
PlayerInfo[playerid][Salt][i] = random(94) + 33;
                
SHA256_PassHash(inputtextPlayerInfo[playerid][Salt], PlayerInfo[playerid][Password], 65);
            }
            new 
query[221];
            
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('%e', '%s', '%e')"PlayerInfo[playerid][Name], PlayerInfo[playerid][Password], PlayerInfo[playerid][Salt]);
            
mysql_tquery(g_SQLquery"OnPlayerRegister""d"playerid 
Reply
#4

Well if it is like that then it is not working. But look at this. It shoud spawn me at defined coords but it spawns me at 0.0, 0.0, 0.0 and it is not even showing
PHP Code:
ShowPlayerDialog(playeridDIALOG_UNUSEDDIALOG_STYLE_MSGBOX"Registration""Account succesfully registered!\nYou have been automaticly logged in""Ok"""); 
from Public OnPlayerRegister(). Like that public won't even execute..
Reply
#5

Since all those are related to MySQL, try keeping only one thread to post all of the problems there.

Okay, as Vince said the loop is only used to generate the salt. Anything else such SHA256_PassHash and mysql functions should be outside of the loop.

Going from one thread to other is a bit confusing so post here the results I mentioned in the other thread. OnPlayerRegister won't be called if an error occurs in mysql_tquery which does in your case.
Reply
#6

First of all I am REALLY sorry for creating 2 post for one problem..

Here is what i got from logs
Code:
[22:07:43] [WARNING] mysql_connect: no password specified (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:59)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '050A613324FDFFABA89C0A1289C7DAA25D59982E354A1C8D9B5A2F2191BDD72C', 'a')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '050A613324FDFFABA89C0A1289C7DAA25D59982E354A1C8D9B5A2F' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', 'EA3041CC98BADF9C3EEFBD32BF8E8B891092476A61FFAD576BD829FAF7509F0B', 'aP')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', 'EA3041CC98BADF9C3EEFBD32BF8E8B891092476A61FFAD576BD829' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', 'F7F9F1439204BD442E128B6A86DA9D434ECC9EFB2D595534F5BCF1F039390119', 'aPx')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', 'F7F9F1439204BD442E128B6A86DA9D434ECC9EFB2D595534F5BCF1' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '3B85E7306DE2F7A3F6525EBEE2D1CA4422CA8B9E1F4B389AC2F696BE258271DA', 'aPxT')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '3B85E7306DE2F7A3F6525EBEE2D1CA4422CA8B9E1F4B389AC2F696' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '9A8762B09C57F55A14DC91B9997A9C2AE093DBAD7B3999462D0A573D34E9E139', 'aPxT/')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '9A8762B09C57F55A14DC91B9997A9C2AE093DBAD7B3999462D0A57' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', 'E71C74686750A3C4303072629F98F450DCCDC071B7CC6C40EDF46A638C2CF5EE', 'aPxT/[')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', 'E71C74686750A3C4303072629F98F450DCCDC071B7CC6C40EDF46A' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '6B0D31BA66240E24E358E9A10F9A9C667C20B62FA6959CC715C6154D393F0F01', 'aPxT/[C')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '6B0D31BA66240E24E358E9A10F9A9C667C20B62FA6959CC715C615' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '2D0F777D8A12E7005A8E97DDD06BA418C4FAB11FEAA245D0A2CFBB23C65E1FEC', 'aPxT/[C9')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '2D0F777D8A12E7005A8E97DDD06BA418C4FAB11FEAA245D0A2CFBB' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '39CBC3D986FE887808FE10F14EBDAC108429E74A1D9519D8B76A64D4B418CA02', 'aPxT/[C9>')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '39CBC3D986FE887808FE10F14EBDAC108429E74A1D9519D8B76A64' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '9C496D505DEBCC1AE2128694A721764E3F8559ABFD6953E7B6B59524B83EFF6E', 'aPxT/[C9>P')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '9C496D505DEBCC1AE2128694A721764E3F8559ABFD6953E7B6B595' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '3BE1932BE1FF234D79BD0D58F10A47E8A43335972F821CE52AF6C15C6A1CBAB0', 'aPxT/[C9>PF')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '3BE1932BE1FF234D79BD0D58F10A47E8A43335972F821CE52AF6C1' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '2B48840022554C3DF79C0970BC47F6B9FAA38C7A0F0F623915FB32D2E70DDB3D', 'aPxT/[C9>PFE')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '2B48840022554C3DF79C0970BC47F6B9FAA38C7A0F0F623915FB32' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', 'DD3B033C2E64A3A38E644E7BB11EDA51435BEA60DCD9B4465DC791126F46106C', 'aPxT/[C9>PFEx')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', 'DD3B033C2E64A3A38E644E7BB11EDA51435BEA60DCD9B4465DC791' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '5AE709F5A30F73E9E8E045BE1E2AF4A3FD368195222705BA2CCEDFB97219C474', 'aPxT/[C9>PFExv')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '5AE709F5A30F73E9E8E045BE1E2AF4A3FD368195222705BA2CCEDF' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', '9F7EB053F906C8638AF97639E21F53A68135F8B8671A6F3FA07413469F4C31EB', 'aPxT/[C9>PFExvz')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', '9F7EB053F906C8638AF97639E21F53A68135F8B8671A6F3FA07413' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
[22:08:10] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('Micko', 'AF587A3694D42D5C8AE26F9FA2167752F689882C33DC9FB0A9D0BACC6DF10D7F', 'aPxT/[C9>PFExvzT')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'salt`), VALUES ('Micko', 'AF587A3694D42D5C8AE26F9FA2167752F689882C33DC9FB0A9D0BA' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:186)
EDIT: Also is this correct?
PHP Code:
for(new 016i++)
            {
                
PlayerInfo[playerid][Salt][i] = random(94) + 33;
            }
            
SHA256_PassHash(inputtextPlayerInfo[playerid][Salt], PlayerInfo[playerid][Password], 65);
             new 
query[221];
            
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `players` (`username`, `password, `salt`), VALUES ('%e', '%s', '%e')"PlayerInfo[playerid][Name], PlayerInfo[playerid][Password], PlayerInfo[playerid][Salt]);
            
mysql_tquery(g_SQLquery"OnPlayerRegister""d"playerid); 
Reply
#7

Error in syntax, you forgot a grave accent ` after password and you didn't remove the mysql functions out of the loop.

Code:
for(new i = 0; i < 16; i++) PlayerInfo[playerid][Salt][i] = random(94) + 33;

SHA256_PassHash(inputtext, PlayerInfo[playerid][Salt], PlayerInfo[playerid][Password], 65);

new query[221];
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `players` (`username`, `password`, `salt`), VALUES ('%e', '%s', '%e')", PlayerInfo[playerid][Name], PlayerInfo[playerid][Password], PlayerInfo[playerid][Salt]);
mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
Reply
#8

Nope. I still got this
Code:
[22:18:44] [WARNING] mysql_connect: no password specified (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:59)
[22:19:13] [ERROR] error #1064 while executing query "INSERT INTO `players` (`username`, `password`, `salt`), VALUES ('Micko', 'A2335C7F2E09A59B69CFDF992A49EDA9C9FC7C2010402C4AC5D9722573F44CA2', 'N68q$_O9g7=e1XtV')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' VALUES ('Micko', 'A2335C7F2E09A59B69CFDF992A49EDA9C9FC7C2010402C4AC5D9722573F44' at line 1 (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:184)
I also checked for ` Everything is fine..
Reply
#9

Yeah, forgot to mention it even though I noticed it before. Remove the comma in `salt`),
Reply
#10

Damn xD One little thing like , made this problem
Thanks for your patience with me guys. Thank you so much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)