[SOLVED] MySQL R7 and login... -
CrossUSAAF - 13.05.2013
Problem already solved!
Re: [HELP] MySQL R7 and Login... -
Vince - 13.05.2013
If you use the cache then you can only use the cache_* functions. You already retrieved the amount of rows through cache_get_data, so there is no need for mysql_num_rows either.
Re: [HELP] MySQL R7 and Login... -
Calabresi - 13.05.2013
Try this:
pawn Code:
public CheckAccount(playerid, account[])
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
SetPVarInt(playerid, "IsRegistered", 1); // Then we set PVar for players that are registered already
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD...);
}
return 1;
}
As Vince said, no need to use mysql_num_rows() in R7.
Re: [HELP] MySQL R7 and Login... -
CrossUSAAF - 13.05.2013
Quote:
Originally Posted by Calabresi
Try this:
pawn Code:
public CheckAccount(playerid, account[]) { new rows, fields; cache_get_data(rows, fields); if(rows) { SetPVarInt(playerid, "IsRegistered", 1); // Then we set PVar for players that are registered already ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD...); } return 1; }
As Vince said, no need to use mysql_num_rows() in R7.
|
Thank you really much Vince and Calabresi. I Didn't know that you can just use "rows", but thank you for that information! Now the login dialog seems to work correctly.
Then this, what I'm wondering: When using "mysql_real_escape", is it same as "%e", escaped string?
Re: [HELP] MySQL R7 and Login... -
Calabresi - 13.05.2013
Quote:
Originally Posted by CrossUSAAF
Thank you really much Vince and Calabresi. I Didn't know that you can just use "rows", but thank you for that information! Now the login dialog seems to work correctly.
Then this, what I'm wondering: When using "mysql_real_escape", is it same as "%e", escaped string?
|
It is indeed, but only if you use mysql_format(). Here is a small example:
pawn Code:
new query[64], pName[MAX_PLAYER_NAME], escname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
mysql_real_escape_string(pName, escname);
format(query, sizeof(query), "UPDATE Name='Testing' WHERE Name='%s'", escname);
mysql_function_query(cHandle, query, false, "OnQueryFinish", "i", playerid);
With mysql_format;
pawn Code:
new query[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
mysql_format(cHandle, query, "UPDATE Name='Testing' WHERE Name='%e'", pName); // '%e' automatically escapes the string.
mysql_function_query(cHandle, query, false, "OnQueryFinish", "i", playerid);
See, it makes things a little easier, at least for me.
Re: [HELP] MySQL R7 and Login... -
CrossUSAAF - 13.05.2013
Thanks for your help guys! Problem solved.