Error in SQLite. Arguement type mismatch error.
#1

OK. so here is the code:

Код:
stock IsPlayerLoggedIn(playerid)
{
    new query[500],name[50],DBResult:res;
	new loggedin;
	GetPlayerName(playerid,name,sizeof(name));
	format(query,sizeof(query),"SELECT * FROM `USERS` WHERE `Name` = '%s'",DB_Escape(name));
	res = db_query(users,query);
 	if(db_num_rows(res))
	{
		db_get_field_assoc(res,"LoggedIn",loggedin,2);
	}
	db_free_result(res);
	if(loggedin == 1) return 1;
	else return 0;
}
Error is:

Код:
error 035: argument type mismatch (argument 3)
Why is it showing error? :-/
Reply
#2

db_get_field_assoc returns a string. You're assigning a single integer value to it. If you want to make it an int, do the following

pawn Код:
stock IsPlayerLoggedIn(playerid)
{
    new query[500],name[50],DBResult:res, str[10];
    new loggedin;
    GetPlayerName(playerid,name,sizeof(name));
    format(query,sizeof(query),"SELECT * FROM `USERS` WHERE `Name` = '%s'",DB_Escape(name));
    res = db_query(users,query);
    if(db_num_rows(res))
    {
        db_get_field_assoc(res,"LoggedIn",str,2);
        loggedin = strval(str);
    }
    db_free_result(res);
    if(loggedin == 1) return 1;
    else return 0;
}
Reply
#3

oh... it works. THANKS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)