Check if phone number exist
#1

Hello,

Is this idea good to check if a phone number exist already?

Код:
new randphone = 0, number = 0, ok = 0, query[64];
					format(query, sizeof(query), "SELECT Phone FROM players WHERE Phone > 0");
					new Cache: numbers = mysql_query(SQL, query);
					do
					{
						ok = 1;
						randphone = 10000 + random(89999);
						if(cache_get_row_count() > 0)
						{
							for(new i, j = cache_get_row_count(); i != j; i++)
							{
								number = cache_get_field_content_int(i, "Phone");
								if(number == randphone)
								{
									ok = 0;
								}
							}
						}
					}
					while(ok == 0);
					cache_delete(numbers);
I don't want to check database everytime, so I made it with cache. I don't know if this code is good... And I want to ask if there is a function better than this one... I don't know if is a good idea to make a loop in another one and I don't want to make an infinite loop than can result in a server freeze.
Reply


Messages In This Thread
Check if phone number exist - by iDark - 02.05.2017, 20:14
Re: Check if phone number exist - by Toroi - 02.05.2017, 20:37
Re: Check if phone number exist - by Vince - 02.05.2017, 20:41
Re: Check if phone number exist - by iDark - 03.05.2017, 08:04

Forum Jump:


Users browsing this thread: 1 Guest(s)