31.01.2014, 16:31
Hi, I am experiencing an issue with my SQL Database where I cannot insert data in when player registers. I tried running the query in the SQL Database Browser and it works fine.
Here is the SQL_Register stock
I use it in the DIALOG_REGISTER dialog after it checks if player is old or new.
And this is how I've checked in OnPlayerConnect
Please help.
Here is the SQL_Register stock
pawn Code:
stock SQL_Register(playerid, passwordstring[])
{
new buff[129];
WP_Hash(buff,sizeof(buff),passwordstring);
new IP[15],Year,Month,Day,date[128];
getdate(Year,Month,Day);
format(date,sizeof(date),"%02d/%02d/%d",Day,Month,Year);
GetPlayerIp(playerid, IP, 15);
format(query, sizeof(query), "INSERT INTO `users` (username,password,ip,score,cash,admin,posx,posy,posz,banned,lastlogin,dlic,cellphone,job,wage,bank) VALUES ('%s','%s','%s','0','0','0','1684.3280','1444.4550','10.7708','0','%s','0','0','0','0','0')",pName(playerid),DB_Escape(buff),IP,date);
db_query(Users,query);
format(string,sizeof(string),"Thanks for registering account with "SERVER_NAME", %s.",pName(playerid));
SendClientMessage(playerid,COLOR_YELLOW,string);
Logged[playerid] = 1;
registered[playerid] = 1;
return 1;
}
pawn Code:
case DIALOG_REGISTER:
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 25)
{
SendClientMessage(playerid,COLOR_RED,"Your password should be in between 1-24 character.");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,""SERVER_NAME" Registration","Welcome to "SERVER_NAME". Your account is not registered with us yet. \nLets do it now by typing chosen password in the input box below.","Register","");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 24) SQL_Register(playerid,DB_Escape(inputtext));
}
if(!response)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,""SERVER_NAME" Registration","Welcome to "SERVER_NAME". Your account is not registered with us yet. \nLets do it now by typing chosen password in the input box below.","Register","");
}
}
pawn Code:
format(query,sizeof(query),"SELECT `username` FROM `users` WHERE `username` = '%s'",pName(playerid));
Result = db_query(Users,query);
if(db_num_rows(Result) == 0) ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,""SERVER_NAME" Registration","Welcome to Eastern Gaming, looks like you're new here.\nChoose a password and insert below in order to play.","Register","");
else
{
format(longstring,sizeof(longstring),"Welcome back to your account %s! \nPlease input your password below to login",pName(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,""SERVER_NAME" Login",longstring,"Login","");
}
db_free_result(Result);