Insert problem
#1

Hey everyone, I've got a weird problem since 2 or 3 days, but I don't know what it is due to. I only know that the problem deals with my 'INSERT INTO' statement:

Script:
pawn Код:
else if(strlen(inputtext) > 4 && strlen(inputtext) < 21)
            {
                new escapedpassword[20], ip[16], query[128], string[128];
                mysql_real_escape_string(inputtext, escapedpassword);
                GetPlayerIp(playerid, ip, sizeof(ip));
                format(query, sizeof(query), "INSERT INTO users(id, username, password, ip, money, score, kills, deaths) VALUES('', '%s', SHA1('%s'), '%s', 0, 0, 0, 0)", pName(playerid), escapedpassword, ip);
                mysql_function_query(connection, query, true, "", ""); // also tried with 'false'
                format(string, sizeof(string), "[SERVER] Account successfully created! (Nickname: %s | Password: %s)", pName(playerid), escapedpassword);
                SendClientMessage(playerid, COLOR_GREEN, string);
            }
mysql_log error:
pawn Код:
[00:03:40] Passing query INSERT INTO users(id, username, password, ip, money, score, kills, deaths) VALUES('0', 'Skyrocker', SHA1('okguy'), '127.0.0.1', |
[00:03:40] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[00:03:40] OnQueryError() - Called.
OnQueryError (samp-server.exe):
pawn Код:
[00:03:40] EID: 1064 | Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 | Query: INSERT INTO users(id, username, password, ip, money, score, kills, deaths) VALUES('0', 'Skyrocker', SHA1('okguy'), '127.0.0.1',
Does anybody know what's wrong?
Reply
#2

1) Increase the size of the query variable to about 175.

2) SHA1 isn't a valid MySQL function.
Reply
#3

OK, I didn't even think about the size of the variable! I also didn't know that SHA1 wasn't used anymore lol

Thanks a lot! :P
Reply
#4

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
1) Increase the size of the query variable to about 175.

2) SHA1 isn't a valid MySQL function.
What? http://dev.mysql.com/doc/refman//5.5...#function_sha1
Reply
#5

My apologies, apparently SHA1 is a valid MySQL function.
Reply
#6

Replace the "INSERT INTO"-part with
pawn Код:
INSERT INTO users(`id`, `username`, `password`, `ip`, `money`, `score`, `kills`, `deaths`)
Reply
#7

Quote:
Originally Posted by Pinguinn
Посмотреть сообщение
Replace the "INSERT INTO"-part with
pawn Код:
INSERT INTO users(`id`, `username`, `password`, `ip`, `money`, `score`, `kills`, `deaths`)
I wrote it without the backquotes and it worked :P It was just the size of my variable.

Problem solved, thank you guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)