18.12.2011, 02:39
I have this piece of code:
When players register on my server, their email address is stored. When new players register, I don't want them using the same email address. Therefore, this function is there to check if the email address is already saved in the DB. Now, my question is; Is the query used in this function the most efficient way to determine if the address exists, or is there an actual syntax for this?
pawn Код:
stock DoesEmailAddressExist(const emailaddress[])
{
new szQuery[300], iReturnVal;
format(szQuery, sizeof(szQuery), "SELECT `Email Address` FROM `Accounts` WHERE `Email Address` = '%s'", emailaddress);
mysql_query(szQuery);
mysql_store_result();
if(mysql_num_rows() > 0)
{
mysql_free_result();
iReturnVal = 1;
}
else if(mysql_num_rows() == 0)
{
mysql_free_result();
iReturnVal = 0;
}
return iReturnVal;
}