PDA

View Full Version : Wrong Value in MySQL


C0oL3r
08/02/2018, 10:25 PM
When i type an age in the dialog box, in the database it's everytime "49"


case DIALOG_AGE:
{
if(!response)
{
if(pInfo[playerid][pLanguage] == 1) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Tasteaza varsta caracterului tau.", "Ok", "Close");
if(pInfo[playerid][pLanguage] == 2) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Type your character age.", "Ok", "Close");
}
if(response)
{
if(!strlen(inputtext))
{
if(pInfo[playerid][pLanguage] == 1) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Tasteaza o varsta cuprinsa intre 13 si 80.\n\nTasteaza varsta caracterului tau.", "Ok", "Close");
if(pInfo[playerid][pLanguage] == 2) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Type a age betweeen 13 and 80.\n\nType your character age.", "Ok", "Close");
}
if(strval(inputtext) < 13 || strval(inputtext) > 80)
{
if(pInfo[playerid][pLanguage] == 1) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Tasteaza o varsta cuprinsa intre 13 si 80.\n\nTasteaza varsta caracterului tau.", "Ok", "Close");
if(pInfo[playerid][pLanguage] == 2) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Type a age betweeen 13 and 80.\n\nType your character age.", "Ok", "Close");
}
if(!IsNumeric(inputtext))
{
if(pInfo[playerid][pLanguage] == 1) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Tasteaza o varsta cuprinsa intre 13 si 80.\n\nTasteaza varsta caracterului tau.", "Ok", "Close");
if(pInfo[playerid][pLanguage] == 2) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age", "Type a age betweeen 13 and 80.\n\nType your character age.", "Ok", "Close");
}
else
{
new AgeQuerry[255];
mysql_format(Database, AgeQuerry, sizeof(AgeQuerry), "UPDATE `USERS` SET `Age` = '%d' WHERE `USERNAME`='%s'", inputtext, pInfo[playerid][pName]);
mysql_query(Database, AgeQuerry);
.....

Kane
08/02/2018, 10:27 PM
Because inputtext is still a string.

You need to turn it into a integer using strval.

Example:

new inputtext[ 4 ] = "250";
new iValue = strval( inputtext ); // iValue is now '250'

http://wiki.sa-mp.com/wiki/Strval

C0oL3r
08/02/2018, 10:44 PM
Thx, you know how to check if a string is a email? like if contains "@"

Mugala
08/02/2018, 11:25 PM
Thx, you know how to check if a string is a email? like if contains "@"

you can find a @ with strfind (tuto link - http://wiki.sa-mp.com/wiki/Strfind)

C0oL3r
08/02/2018, 11:30 PM
Thanks!

PepsiCola23
09/02/2018, 08:50 AM
its useless to try and find @ because fake emails can still be put. x@y.z ..even if you try to find the big email names it still wont assure you there are not going to be any false emails...so working for nothing imo.

just tell them to use correct email because they`ll need it to reset their passwords and let them decide if they put their email or not.

Mugala
09/02/2018, 09:38 AM
its useless to try and find @ because fake emails can still be put. x@y.z ..even if you try to find the big email names it still wont assure you there are not going to be any false emails...so working for nothing imo.

just tell them to use correct email because they`ll need it to reset their passwords and let them decide if they put their email or not.

for that reasons, you can check a whole mail or just send the verification code or something like this to his mail for confirm the mail.

C0oL3r
09/02/2018, 06:33 PM
i know that will be fake emails, but if they want to recover the account if it will forgot the password it will put the real email, if not, succes with a new account