Mysql Problem
#1

I have this code,

pawn Код:
format(stq,sizeof(stq),"Weapon Cheats, Weapon: %d",BannedWeapons[j]);

CheckMySQL();

format(string, sizeof(string), "INSERT INTO bans (Name,IPAddress,Reason,BanExpiring,Date) VALUES ('%s','%s','%s','%s','%s')", PlayerName(i),GetIP(i),stq,str);
mysql_query(string);
But Im getting errored in the mysql log.

The error is as follows

Check the manual that corresponds to your MySQL server version for the right syntax to use near ''Weap' at line 1)

Reguards
Reply
#2

1) You are having 5 x %s in the format, but you only insert 4 strings into it.
2) Try;
pawn Код:
format(string, sizeof(string), "INSERT INTO `bans` (`Name`,`IPAddress`,`Reason`,`BanExpiring`,`Date`) VALUES ('%s','%s','%s','%s','%s')", PlayerName(i),GetIP(i),stq,str, gettime());
mysql_query(string);
Reply
#3

I know, I relised that. still the same error.

[12:53:47] CMySQLHandler::Query(INSERT INTO bans (Name,IPAddress,Reason,BanExpiring,Date) VALUES ('Mr_Manny','94.171.212.124','Weap) - An error has occured. (Error ID: 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 ''Weap' at line 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)