MySQL DoesAccountExists
#1

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;
}
Reply
#2

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
Reply
#3

Works thanks!
I have one question:

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)