[MSQL]Need help a bit.. with explaining how to do it right... - 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: [MSQL]Need help a bit.. with explaining how to do it right... (
/showthread.php?tid=569088)
[MSQL]Need help a bit.. with explaining how to do it right... -
Scrillex - 28.03.2015
So I need some explanation how can I update this to r39.. Because I need some seriuss help... With this funcition.
EROOR:
pawn Code:
error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_num_rows"
pawn Code:
new Query[200], escpname[24];
mysql_real_escape_string(sendername, escpname);
format(Query, sizeof(Query), "SELECT * FROM `players` WHERE `Name` = '%s'", escpname);
mysql_query_ex(Query);
mysql_store_result();
if(mysql_num_rows() != 0) //If the user is found
{
gPlayerAccount[playerid] = 1;
}
else
{
gPlayerAccount[playerid] = 0;
}
Re: [MSQL]Need help a bit.. with explaining how to do it right... -
DeitY - 28.03.2015
Did you download Blueg-s mysql plugin, and a_mysql.inc update?
Re: [MSQL]Need help a bit.. with explaining how to do it right... -
AndySedeyn - 28.03.2015
Strings can be escaped with the '%e' specifier in your format.
These are functions you should take a look at:
mysql_format and mysql_tquery as well as the 'cache_' functions.
https://sampwiki.blast.hk/wiki/MySQL/R33
Re: [MSQL]Need help a bit.. with explaining how to do it right... -
JeaSon - 28.03.2015
as bible already said use %e to escapename here example
pawn Code:
stock LoginPlayer(playerid)
{
new Query[200], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
mysql_format(MySQLConnection,Query, sizeof(Query), "SELECT * FROM `players` WHERE `Name` = '%e'", name);// in mysqlconnection put yours one
mysql_tquery(MySQLConnection, Query, "OnPlayerLogin","d",playerid);
}
public OnPlayerLogin(playerid)
{
new Query[200], name[24], rows, fields;
GetPlayerName(playerid, name , sizeof(name));
cache_get_data(rows,fields,mysqlConnectin);
if(rows) //If the user is found
{
gPlayerAccount[playerid] = 1;
}
else
{
gPlayerAccount[playerid] = 0;
}
return 1;
}