MySQL help me please.
#1

Hello, I made this code. but when i add the IP insert it doesn't work, but without IP it works.

Код:
stock CreateAccount(playerid, salt[], pass[129])
{
	new query[240], escapedPlayerName[MAX_PLAYER_NAME], IP[16];
	mysql_real_escape_string(GetName2(playerid), escapedPlayerName);
	GetPlayerIp(playerid, IP, sizeof(IP));
	format(query, sizeof(query), "INSERT INTO `users` (name, salt, password, IP) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')",escapedPlayerName,salt,pass,IP);
	mysql_function_query(dbHandle, query, false, "OnAccountCreate", "d", playerid);
}
what is the problem with the IP?
Reply
#2

I did not bother to dig too deep, but why are you escaping single quotes? They are necessary for the query, yet don't have an effect inside the string for PAWN.

Remove the escape characters (\).
Reply
#3

still the same problemo.

mysql debug

Код:
[16:28:32] Passing query INSERT INTO `users` (name, salt, password, IP) VALUES ('Vincent_Leighton', '0IN1757sEA588tt87p53756u82G9As', '463AF90AAE11771CF943309984E6594837231F2DD0B641DB338C8B01B7370E2C906EEC129A9FA33B64678D087D3E0CD6AD5E6121D28498B4D6C3F70137C00441' | d
[16:28:32] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
Reply
#4

Your query string isn't big enough.

You have to increase the cells. With name, password and IP, you will (on maximum) reach 247 cells. There's already 7 cells to much, and you still need to add salt into there. I have no idea what salt is - honestly - but I know it requires space.
Reply
#5

SO WHAT SHOULD i DO THEN?
Reply
#6

set new query[240] to new query[1024] for example.
And why are you not using SHA1() to hash passwords?
Anyway try to set the string larger.
Reply
#7

Quote:
Originally Posted by Roel
Посмотреть сообщение
set new query[240] to new query[1024] for example.
And why are you not using SHA1() to hash passwords?
Anyway try to set the string larger.
Isn't 1024 a bit over the top? He only needs 247 + whatever the maximum length of salt[] is - which I have no knowledge of - which I believe won't be over 200 cells big.
Reply
#8

Kay, fixed it:

format(query, sizeof(query), "INSERT INTO `users` (name, password, playerIP) VALUES ('%s', SHA1('%s'), '%s')",escapedPlayerName,pass,IP);

last question:
how do i check if input in dialog is SHA1??..
Reply
#9

You hash inputtext with SHA1 and then compare the result with the hashed password in the database.
Reply
#10

thank you guys for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)