SA-MP Forums Archive
Mysql Problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql Problem (/showthread.php?tid=166888)



Mysql Problem - Kyle - 10.08.2010

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


Re: Mysql Problem - woot - 10.08.2010

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);



Re: Mysql Problem - Kyle - 10.08.2010

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)