SA-MP Forums Archive
Help with MySQL Database Check - 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: Help with MySQL Database Check (/showthread.php?tid=417523)



Help with MySQL Database Check - Xeiss - 21.02.2013

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


Re: Help with MySQL Database Check - Misiur - 21.02.2013

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