SA-MP Forums Archive
Wrong Value in MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Wrong Value in MySQL (/showthread.php?tid=649433)



Wrong Value in MySQL - C0oL3r - 08.02.2018

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);
                                        .....



Re: Wrong Value in MySQL - Kane - 08.02.2018

Because inputtext is still a string.

You need to turn it into a integer using strval.

Example:
PHP код:
new inputtext] = "250";
new 
iValue strvalinputtext ); // iValue is now '250' 
https://sampwiki.blast.hk/wiki/Strval


Re: Wrong Value in MySQL - C0oL3r - 08.02.2018

Thx, you know how to check if a string is a email? like if contains "@"


Re: Wrong Value in MySQL - Mugala - 08.02.2018

Quote:
Originally Posted by C0oL3r
Посмотреть сообщение
Thx, you know how to check if a string is a email? like if contains "@"
you can find a @ with strfind (tuto link - https://sampwiki.blast.hk/wiki/Strfind)


Re: Wrong Value in MySQL - C0oL3r - 08.02.2018

Thanks!


Re: Wrong Value in MySQL - PepsiCola23 - 09.02.2018

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.


Re: Wrong Value in MySQL - Mugala - 09.02.2018

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
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.


Re: Wrong Value in MySQL - C0oL3r - 09.02.2018

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