return mysql callback (GStylezzz)
#1

Hello. I made a function IsUsernameTaken and I want when its called to return false or true depending on is there row with column username with the player's username
so here is my function:
Код:
stock IsUsernameTaken(playerid){
			new query[256],function_result, user[MAX_PLAYER_NAME];
			mysql_real_escape_string(Username(playerid), user, handle);
			format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `user` = '%s' LIMIT 0,1", user);
			print(query);
			mysql_query(query, MYSQL_IS_USERNAME_TAKEN, playerid, handle);
	        return function_result;
}
And here is the MySQL callback
Код:
case MYSQL_IS_USERNAME_TAKEN:
		{
		    new query_result;
			mysql_store_result(handle);
			query_result = mysql_num_rows(handle);
			mysql_free_result(handle);
			if(query_result == 1){
			    print("true");
			}
			else {
				print("false");
			}
		}
Can I and how to send the result back to the function and return the result ?
Reply
#2

Impossible. There's some include that allow you to do inline queries, but I don't know how that works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)