mySQL error
#9

Quote:
Originally Posted by Antenastyle
Посмотреть сообщение
There are some functions that in the newest versions aren't. Anyways, which version do you recommend me to use?
I promise you that whichever functions you're thinking of (do share) either still exist or have been purposefully replaced with a better version/method. The latest version is obviously recommended since it'll have the most recent features and have patches of bugs within older versions. The current method you're using is completely wrong, of course it sends the message regardless of the outcome of the query. You should use threaded queries, which will also help with debugging not to mention server performance. You're also exposing yourself to SQL injection by not escaping user strings. The mysql_format has an inline %e specifier to escape strings (as appose to using %s), along with the mysql_escape_string function.

Example:
pawn Код:
// in command
new local_query[100];
mysql_format(SQLHandle, local_query, sizeof local_query, "INSERT QUERY");
mysql_tquery(SQLHandle, local_query, "OnAccountCreated", "i", playerid);

forward OnAccountCreated(playerid);
public OnAccountCreated(playerid)
{
       if(cache_affected_rows() == 0)
             return SendClientMessage(playerid, -1, "Unable to create account.");
 
       new
             local_string[64];

       format(local_string, sizeof local_string, "Account created, row ID: %d.", cache_insert_id());
       SendClientMessage(playerid, -1, local_string);

       // do whatever else
       return 1;
}
You can find recent plugin releases here.
Reply


Messages In This Thread
mySQL error - by Antenastyle - 02.06.2017, 16:20
Re: mySQL error - by SyS - 02.06.2017, 16:28
Re: mySQL error - by Antenastyle - 02.06.2017, 16:32
Re: mySQL error - by SyS - 02.06.2017, 16:37
Re: mySQL error - by Antenastyle - 02.06.2017, 16:50
Re: mySQL error - by Vince - 02.06.2017, 17:39
Re: mySQL error - by Antenastyle - 02.06.2017, 17:44
Re: mySQL error - by GoldenLion - 02.06.2017, 17:59
Re: mySQL error - by Abagail - 02.06.2017, 20:12

Forum Jump:


Users browsing this thread: 1 Guest(s)