MySQL syntax error - 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: MySQL syntax error (
/showthread.php?tid=585617)
MySQL syntax error -
sjames - 15.08.2015
Код:
forward OfflineBanCheck(adminid, reason[]);
public OfflineBanCheck(adminid, reason[])
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
new ip[16], name[MAX_PLAYER_NAME], seconds, query[144], string[128];
cache_get_field_content(0, "Name", name, mysql, MAX_PLAYER_NAME);
cache_get_field_content(0, "IP", ip);
seconds = (gettime()+604800);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `bans` (`Player`, `IP`, `Reason`, `Unban date`, `Banned by`) VALUES ('%e', '%e', '%e', '%d', '%e')", name, ip, reason, seconds, Name(adminid));
mysql_tquery(mysql, query, "", "");
SendClientMessage(adminid, C_LRED, "Player banned!");
} else return SendClientMessage(adminid, C_LRED, "Player not found!");
return 1;
}
And error:
Код:
[08:19:12] [DEBUG] mysql_tquery - scheduling query "INSERT INTO `bans` (`Player`, `IP`, `Reason`, `Unban date`, `Banned by`) VALUES ('noob123', '94.123.200.55', 'Reason', '1440245952', '"..
[08:19:12] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[08:19:12] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[08:19:12] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[08:19:12] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
[08:19:12] [DEBUG] CMySQLQuery::Execute[()] - error will be triggered in OnQueryError
[08:19:12] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[08:19:12] [DEBUG] Calling callback "OnQueryError"..
Cant see the mistake here, hmm?
Re: MySQL syntax error -
sjames - 15.08.2015
Hmm I really cant spot a mistake.
Re: MySQL syntax error -
finelaq - 15.08.2015
Maybe query size is too small?
Re: MySQL syntax error -
Syzygy1 - 15.08.2015
You don't need to put integer values inside quotation marks:
should just be
Re: MySQL syntax error -
Vince - 15.08.2015
Quote:
Originally Posted by finelaq
Maybe query size is too small?
|
This, mostly.
However, take note that in a properly normalized database a player's name only appears
once in the
entire database and all tables that need the information have to reference that one table. This makes it so that if you change a player's name you only need to change it one place only and thus avoid data corruption.