Anyone can help me correct some public functions please? - 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: Anyone can help me correct some public functions please? (
/showthread.php?tid=520180)
Anyone can help me correct some public functions please? -
AMouldyLemon - 17.06.2014
pawn Код:
forward MasterAccountRegister(playerid); // Register a new Master Account if name not already in use.
public MasterAccountRegister(playerid)
{
if(!AccountExists(playerid))
{
format(mysql_query, sizeof(mysql_query), "INSERT INTO `Master` ( `username` , `password` , `email_address` , `ip_address` , `super_admin` , `old_ip` ) VALUES ( '%s' , '%s', '%s', '%s', 0, 'UNKNOWN' )", mysql_real_escape_string(PlayerName(playerid)), mysql_real_escape_string(GetPVarStringEx(playerid, "TEMP_PASSWORD")), mysql_real_escape_string(GetPVarStringEx(playerid, "TEMP_EMAIL")), GetPlayerIPEx(playerid));
mysql_free_result(mysql_query(database,mysql_query));
DeletePVar(playerid,"TEMP_EMAIL");
DeletePVar(playerid,"TEMP_PASSWORD");
printf("%s has successfully registered.", cName(playerid));
return true;
}
return false;
}
pawn Код:
(528) : error 076: syntax error in the expression, or invalid function call
(528) : error 072: "sizeof" operator is invalid on "function" symbols
(529) : error 017: undefined symbol "mysql_free_result"
(532) : error 012: invalid function call, not a valid address
(532) : warning 215: expression has no effect
(532) : error 001: expected token: ";", but found ")"
(532) : error 029: invalid expression, assumed zero
(532) : fatal error 107: too many error messages on one line
Re: Anyone can help me correct some public functions please? -
Konstantinos - 17.06.2014
There are many issues with the above:
- Don't use "mysql_query" for the query's name but some other name.
- The function mysql_free_result does not exist.
- mysql_real_escape_string returns the number of escaped characters and not the modified output of the string.
Like I said in your previous thread, you should update to R39 and then it can be:
pawn Код:
new Query[300]; // increase the size if it's not enough
mysql_format(database, Query, sizeof (Query), "INSERT INTO Master (username,password,email_address,ip_address,super_admin,old_ip) VALUES ('%e' , '%e', '%e', '%e', 0, 'UNKNOWN')", PlayerName(playerid), GetPVarStringEx(playerid, "TEMP_PASSWORD"), GetPVarStringEx(playerid, "TEMP_EMAIL"), GetPlayerIPEx(playerid));
mysql_tquery(database, Query, "", "");
Re: Anyone can help me correct some public functions please? -
AMouldyLemon - 17.06.2014
GetPVarStringEx?
(I'm on r39)
EDIT: Got it, thanks