mysql problem
#1

hi.i have this error in mysql:
Код:
[Fri Jun 10 18:57:32 2016] Connected (0) to x @ x via TCP/IP.
[Fri Jun 10 18:57:32 2016] MySQL Server Version 5.5.50-cll.
[Fri Jun 10 18:58:08 2016] Error (0): Failed to exeute 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 ''No' at line 1.
and these are all codes about mysql in my gamemode:
Код:
new MySQL:connection;
////ongamemodeinit/////
connection=mysql_init(LOG_ONLY_ERRORS,1);
mysql_connect("x","x","x","modernga_codaw",connection);
    new handle[4096];
    strcat(handle,"CREATE TABLE IF NOT EXISTS codbb_serverusers(Name VARCHAR(24),AID INT(10),Status INT(1),Ip VARCHAR(16),RegisterDate VARCHAR(10)");
    strcat(handle,",Password VARCHAR(20),HashPW VARCHAR(129),AdminBan VARCHAR(24),ReasonBan VARCHAR(128),DateBan VARCHAR(10),BanTime INT(20),AdminLevel INT(1),VipLevel INT(1)");
    strcat(handle,",VipTime INT(20),Score INT(15),Money INT(20),Kills INT(10),KillSpree INT(10),Deaths INT(10),DeathSpree INT(10),Ratio Float(20),Zones INT(10),ZoneSpree INT(10)");
    strcat(handle,",Warn INT(1),ClanID INT(5),ClanName VARCHAR(24),ClanTag VARCHAR(6),ClanLevel INT(3),AirLicenseStatus INT(1),GroundLicenseStatus INT(1),AdminAirLicense VARCHAR(24)");
    strcat(handle,",AdminGroundLicense VARCHAR(24),Registered INT(1),Jailed INT(1),Muted INT(1),Freezed INT(1),RconStatus INT(1),Clan INT(1),Leader INT(1),GroundLicense INT(1),AirLicense INT(1)");
    strcat(handle,",SKILL_PISTOL INT(3),SKILL_PISTOL_SILENCED INT(3),SKILL_DESERT_EAGLE INT(3),SKILL_SHOTGUN INT(3),SKILL_SAWNOFF_SHOTGUN INT(3),SKILL_SPAS12_SHOTGUN INT(3),SKILL_MICRO_UZI INT(3)");
	strcat(handle,",SKILL_MP5 INT(3),SKILL_AK47 INT(3),SKILL_M4 INT(3),SKILL_SNIPERRIFLE INT(3))");
	mysql_query(handle);
Код:
///// in register ///////////////
new handle[4096];
    strcat(handle,"INSERT INTO `codbb_serverusers`(Name,AID,Status,Ip,RegisterDate");
    strcat(handle,",Password,HashPW,AdminBan,ReasonBan,DateBan,BanTime,AdminLevel,VipLevel");
    strcat(handle,",VipTime,Score,Money,Kills,KillSpree,Deaths,DeathSpree,Ratio,Zones,ZoneSpree");
    strcat(handle,",Warn,ClanID,ClanName,ClanTag,ClanLevel,AirLicenseStatus,GroundLicenseStatus,AdminAirLicense");
    strcat(handle,",AdminGroundLicense,Registered,Jailed,Muted,Freezed,RconStatus,Clan,Leader,GroundLicense,AirLicense)");
    format(str,sizeof(str),"VALUES('%s',%d,1,'%s','%s','%s','%s','None','None','None',0,0,0,0,0,100000,0,0,0,0,0.00,0,0,0,-1,'None','None',0,1,1,'None','None',1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)",PlayerName(playerid),dini_Int(file,"AID"),PlayerIp(playerid),dini_Get(file,"RegisterDate"),inputtext,buf);
    strcat(handle,str);
    mysql_query(handle);
plz help me.
Reply
#2

please help me.
Reply
#3

Try
Код:
new MySQL:connection;
////ongamemodeinit/////
connection=mysql_init(LOG_ONLY_ERRORS,1);
mysql_connect("x","x","x","modernga_codaw",connection);
new handle[4096];
strcat(handle,"CREATE TABLE IF NOT EXISTS codbb_serverusers(Name VARCHAR(24),AID INT(10),Status INT(1),Ip VARCHAR(16),RegisterDate VARCHAR(10)");
strcat(handle,",Password VARCHAR(20),HashPW VARCHAR(129),AdminBan VARCHAR(24),ReasonBan VARCHAR(128),DateBan VARCHAR(10),BanTime INT(20),AdminLevel INT(1),VipLevel INT(1)");
strcat(handle,",VipTime INT(20),Score INT(15),Money INT(20),Kills INT(10),KillSpree INT(10),Deaths INT(10),DeathSpree INT(10),Ratio Float,Zones INT(10),ZoneSpree INT(10)");
strcat(handle,",Warn INT(1),ClanID INT(5),ClanName VARCHAR(24),ClanTag VARCHAR(6),ClanLevel INT(3),AirLicenseStatus INT(1),GroundLicenseStatus INT(1),AdminAirLicense VARCHAR(24)");
strcat(handle,",AdminGroundLicense VARCHAR(24),Registered INT(1),Jailed INT(1),Muted INT(1),Freezed INT(1),RconStatus INT(1),Clan INT(1),Leader INT(1),GroundLicense INT(1),AirLicense INT(1)");
strcat(handle,",SKILL_PISTOL INT(3),SKILL_PISTOL_SILENCED INT(3),SKILL_DESERT_EAGLE INT(3),SKILL_SHOTGUN INT(3),SKILL_SAWNOFF_SHOTGUN INT(3),SKILL_SPAS12_SHOTGUN INT(3),SKILL_MICRO_UZI INT(3)");
strcat(handle,",SKILL_MP5 INT(3),SKILL_AK47 INT(3),SKILL_M4 INT(3),SKILL_SNIPERRIFLE INT(3))");
mysql_query(handle);

///// in register ///////////////
new handle[4096];
strcat(handle,"INSERT INTO `codbb_serverusers`(Name,AID,Status,Ip,RegisterDate");
strcat(handle,",Password,HashPW,AdminBan,ReasonBan,DateBan,BanTime,AdminLevel,VipLevel");
strcat(handle,",VipTime,Score,Money,Kills,KillSpree,Deaths,DeathSpree,Ratio,Zones,ZoneSpree");
strcat(handle,",Warn,ClanID,ClanName,ClanTag,ClanLevel,AirLicenseStatus,GroundLicenseStatus,AdminAirLicense");
strcat(handle,",AdminGroundLicense,Registered,Jailed,Muted,Freezed,RconStatus,Clan,Leader,GroundLicense,AirLicense");
strcat(handle,",SKILL_PISTOL,SKILL_PISTOL_SILENCED,SKILL_DESERT_EAGLE,SKILL_SHOTGUN,SKILL_SAWNOFF_SHOTGUN,SKILL_SPAS12_SHOTGUN,SKILL_MICRO_UZI");
strcat(handle,",SKILL_MP5,SKILL_AK47,SKILL_M4,SKILL_SNIPERRIFLE)");
format(str,sizeof(str),"VALUES('%s',%d,1,'%s','%s','%s','%s','None','None','None',0,0,0,0,0,100000,0,0,0,0,0.00,0,0,0,-1,'None','None',0,1,1,'None','None',1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)",PlayerName(playerid),dini_Int(file,"AID"),PlayerIp(playerid),dini_Get(file,"RegisterDate"),inputtext,buf);
strcat(handle,str);
mysql_query(handle);
Reply
#4

new error:
Код:
[Sat Jun 11 00:07:30 2016] Error (0): Failed to exeute 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.
Reply
#5

In your second query, you're resetting the string when you use format.
You need to do it like this:

Код:
format(handle, sizeof (handle), "%sVALUES...", handle, the values here);
Reply
#6

Quote:
Originally Posted by Stinged
Посмотреть сообщение
In your second query, you're resetting the string when you use format.
You need to do it like this:

Код:
format(handle, sizeof (handle), "%sVALUES...", handle, the values here);
Код:
format(str,sizeof(str),"VALUES(...");
strcat(handle,str);
Reply
#7

Oh sorry, I didn't see that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)