Help with MySQL Database Check
#1

Hi. I'm new to the MySQL RC7 with the caching and all.
I did this:
Код:
public OnPlayerConnect(playerid) {
	new rows, fields;
	format(str, sizeof(str), "SELECT `id` FROM `users` WHERE `username` = '%s'", GetName(playerid));
	mysql_function_query(mysql_con, str, true, "", "d", playerid);
	cache_get_data(rows, fields);
	if (!rows) {
		SendClientMessage(playerid, COLOR_RED, "You aren't registered.");
	} else {
		SendClientMessage(playerid, COLOR_GREEN, "You are registered.");
	}
	return 1;
}
And it always says that the user isn't registered, even when the username exists in the database.
Why does this happen? And I'll be really happy if you could give me a link to a good MySQL RC7 with caching tutorial.
Thanks
Reply
#2

pawn Код:
public OnPlayerConnect(playerid) {
    mysql_format(mysql_con, str, "SELECT `id` FROM `users` WHERE `username` = '%e'", GetName(playerid));
    mysql_function_query(mysql_con, str, true, "FetchUser", "d", playerid);
    return 1;
}
forward FetchUser(pid);
public FetchUser(pid) {
    new rows, fields;
    cache_get_data(rows, fields);
    if (!rows) {
        SendClientMessage(pid, COLOR_RED, "You aren't registered.");
    } else {
        SendClientMessage(pid, COLOR_GREEN, "You are registered.");
    }
    return 1;
}
https://sampforum.blast.hk/showthread.php?tid=337810 this is best tutorial you can get
Reply


Forum Jump:


Users browsing this thread: