SA-MP Forums Archive
MySQL DoesAccountExists - 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: MySQL DoesAccountExists (/showthread.php?tid=655857)



MySQL DoesAccountExists - KamilPolska - 01.07.2018

How to convert to MySQL BlueG ?

StrickenKid:
Код:
MySQL_DoesAccountExist(nick[])
{
    new string[128];
    format(string, sizeof(string), "SELECT `nickname` FROM `accounts` WHERE `nickname` = BINARY '%s'", nick);
    mysql_query(string);
    mysql_store_result();
    new result = mysql_num_rows();
    mysql_free_result();

    if(result > 0)
    {
        return -1;
    }
    else
    {
        format(string, sizeof(string), "SELECT `nickname` FROM `accounts` WHERE `nickname` = '%s'", nick);
    	mysql_query(string);
    	mysql_store_result();
    	result = mysql_num_rows();
    	mysql_free_result();
        if(result > 0) return -999;
    }
    return 0;
}



Re: MySQL DoesAccountExists - anmelvin - 01.07.2018

PHP код:
MySQL_DoesAccountExist(nick[])
{
    new 
string[128];
    
mysql_format('Your SQL Handle'stringsizeof(string), "SELECT `nickname` FROM `accounts` WHERE `nickname` = BINARY '%s'"nick);
    
mysql_tquery('Your SQL Handle'string"OnAccountExistCheck""s"nick);
}
forward OnAccountExistCheck(nick[]);
public 
OnAccountExistCheck(nick[]) {
   if(
cache_num_rows() == 0) {
   return 
false;
   }
   return 
true;

should work like this


Re: MySQL DoesAccountExists - KamilPolska - 03.07.2018

Works thanks!
I have one question:

Is this necessary?
Код:
mysql_store_result();
mysql_free_result();



Re: MySQL DoesAccountExists - jasperschellekens - 03.07.2018

Quote:
Originally Posted by KamilPolska
Посмотреть сообщение
Works thanks!
Is this necessary?
Absolutely.
https://dev.mysql.com/doc/refman/8.0...ee-result.html


Re: MySQL DoesAccountExists - anmelvin - 07.07.2018

Quote:
Originally Posted by KamilPolska
Посмотреть сообщение
Works thanks!
I have one question:

Is this necessary?
Код:
mysql_store_result();
mysql_free_result();
It's not. It was needed in earlier versions of the MySQL plugin but it's not anymore.