MySQL Error:
#1

Quote:

[02/16/14 11:28:35] Error (0): Could not execute query. 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.

Line:
pawn Код:
format(query, sizeof(query), "INSERT INTO `bans` (UserID, Username, AdminName,BanReason,Date) VALUES('%d','%s', '%s','OFFLINE BAN', '%d-%d-%d')", DataString,tmp,sendername,month,day,year);
When I remove UserID and its values, it works fine. When I add it, it doesn't work.
Reply
#2

try
pawn Код:
format(query, sizeof(query), "INSERT INTO `bans` (`UserID`,`Username`,`AdminName`,`BanReason`,`Date`) VALUE ('%d','%s','%s','OFFLINE BAN','%d-%d-%d')", DataString,tmp,sendername,month,day,year);
Reply
#3

Quote:

[02/16/14 14:42:31] Error (0): Could not execute query. 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 ''OFFLI' at line 1.

Well yeah
Reply
#4

Fairly obvious that it's being cut off at that point, which in turn means your string isn't big enough.
Reply
#5

Yeah, you would think so, right?

I increased the string several times. Currently its 1056. And yet, thats still the same thing.
Reply
#6

Is the date column a datetime type? If so you need to use the native SQL functions to call the a date, as '%d-%d-%d' is threated as a string (char). Either change the date column to a string type (varchar) or just use NOW() to get the current date and time.

Also, is the UserID formatted parameter (DataString) a string or an integer? You're using a '%d' which means decimal or integer, and the inserted parameters looks like a string by the name of it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)