MySQL R39 Help
#1

hello

Since r39 released , i'm using it while still no tutorial explains it >_>

I converted my register system and login by practice from old tutorials,

Problem is , no errors when compiling,
It dosen't save player in db

and
Код:
 
[18:13:27] [ERROR] CMySQLQuery::Execute[OnAccountRegister] - (error #1064) 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 'VALUES( 'Tsaer', '0C528763C61AA99EDBC175084DD942F4ADE26CED32CEC7BBDD2AB4164FF832' at line 1
Tsaer is user name i used to test my system and yea so...

It told me that something wrong with line and on account register

here's code:
pawn Код:
CMD:register(playerid, params[])
{
    new query[300], str[128], password[50];
    GetPlayerName(playerid, Name[playerid], MAX_PLAYER_NAME);
    GetPlayerIp(playerid, IP[playerid], 16);
    if(IsPlayerLoggedIn[playerid] == 1) return SCM(playerid, red, "[ERROR] You are already registered!");
    if(sscanf(params, "s[75]", password)) return SendClientMessage(playerid, red, "[ERROR] USAGE:/register [password]");
    if(strlen(params) < 6) return SendClientMessage(playerid, red, "[ERROR] Password is too short! Min Length: 6 , MAX : 12");
    WP_Hash(pInfo[playerid][Password], 129, params);
    mysql_format(mysql, query, sizeof(query), "INSERT INTO `users` (`Username` , `Password`, `IP`, VALUES( '%s', '%s', '%s')", Name[playerid], pInfo[playerid][Password], IP[playerid]);
    mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
    SendClientMessage(playerid, lgreen, "[ACCOUNT] You have successfully created an account!");
    GameTextForPlayer(playerid, "~g~REGISTERED~g~", 2, 5000);
    IsPlayerLoggedIn[playerid] = 1;
    IsPlayerRegistered[playerid] = 1;
    return 1;
}
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
    new id = pInfo[playerid][UID];
    id = cache_insert_id();
    return 1;
}
please help..
Reply
#2

pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `users` (`Username` , `Password`, `IP`, VALUES( '%s', '%s', '%s')", Name[playerid], pInfo[playerid][Password], IP[playerid]);
Remove the , after `IP`
Reply
#3

not working :/
Reply
#4

pawn Код:
INSERT INTO `users` (`Username` , `Password`, `IP`) VALUES ('%s', '%s', '%s')
Reply
#5

Thanks!! 14 days trying to fix it lol, and a stupid mistake can do this, thank you again, both repped for helping
Reply
#6

Quote:
Originally Posted by Xabi
Посмотреть сообщение
pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `users` (`Username` , `Password`, `IP`, VALUES( '%s', '%s', '%s')", Name[playerid], pInfo[playerid][Password], IP[playerid]);
Remove the , after `IP`
Yes, you are right remove the , after IP, but he's missing an bracket, to close the first part.

Quote:
Originally Posted by Scottas
Посмотреть сообщение
pawn Код:
INSERT INTO `users` (`Username` , `Password`, `IP`) VALUES ('%s', '%s', '%s')
This would fix, but can be improved or you will be a victim of SQL Injections, without escaping strings


This should work.
pawn Код:
INSERT INTO `users` (Username , Password, IP) VALUES ('%e', '%e', '%e')
Reply
#7

code is working good now and yea username would have %s and %e but ip and ip are %s cause i didn't put them as varchars
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)