[MySQL] INSERT INTO help -
Tigerkiller - 30.01.2012
Hello Community.
I tryed to Create my Own MySQL Login/Registersystem but when i try to register it gives me an syntax error:
Код:
[Mon Jan 30 03:36:25 2012] 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 'Alter, Geschlecht, Muted, Freezed, Tutorial) VALUES ('[GRW]Firebird','TestPasswort',' at line 1.
My Register Code are as following:
pawn Код:
public OnPlayerRegister(playerid,key[])
{
printf("playerid: %i - Passwort: %s",playerid,key);
new Name[MAX_PLAYER_NAME], Query[500], escname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof Name);
mysql_real_escape_string(Name,escname);
format(Query,sizeof Query,"INSERT INTO `Accounts` (Nickname, Passwort, Admin, Level, Respect, Geld, Handy, HandyGeld, Fraktion, Leader, Alter, Geschlecht, Muted, Freezed, Tutorial) VALUES ('%s','%s',0,1,0,20000,1,50,0,0,0,0,0,0,0)",escname,key);
printf("%s",Query);
mysql_query(Query);
}
Database:
Код:
CREATE TABLE `GRW`.`Accounts` (
`ID` INT( 255 ) NOT NULL AUTO_INCREMENT ,
`Nickname` VARCHAR( 30 ) NOT NULL ,
`Passwort` VARCHAR( 20 ) NOT NULL ,
`Admin` INT( 2 ) NOT NULL ,
`Level` INT( 100 ) NOT NULL ,
`Respect` INT( 100 ) NOT NULL ,
`Geld` INT( 50 ) NOT NULL ,
`Handy` INT( 2 ) NOT NULL ,
`HandyGeld` INT( 100 ) NOT NULL ,
`Fraktion` INT( 3 ) NOT NULL ,
`Leader` INT( 3 ) NOT NULL ,
`Alter` INT( 2 ) NOT NULL ,
`Geschlecht` INT( 1 ) NOT NULL ,
`Muted` INT( 1 ) NOT NULL ,
`Freezed` INT( 1 ) NOT NULL ,
`Tutorial` INT( 1 ) NOT NULL ,
PRIMARY KEY ( `ID` )
) ENGINE = MYISAM ;
Iam using Strickenkid's MySQL Plugin and i dont get any errors.
can anyone tell me whats wrong on the syntax ?
Regards Tigerkiller
Re: [MySQL] INSERT INTO help -
Ricop522 - 30.01.2012
pawn Код:
public OnPlayerRegister(playerid,key[])
{
printf("playerid: %i - Passwort: %s",playerid,key);
new Name[MAX_PLAYER_NAME], Query[500], escname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof Name);
mysql_real_escape_string(Name,escname);
format(Query,sizeof Query,"INSERT INTO `Accounts` \
(Nickname, \
Passwort, \
Admin, \
Level, \
Respect, \
Geld, \
Handy, \
HandyGeld, \
Fraktion, \
Leader, \
Alter, \
Geschlecht, \
Muted, \
Freezed, \
Tutorial) \
VALUES \
('%s',\
'%s',\
'0',\
'1',\
'0',\
'20000',\
'1',\
'50',\
'0',\
'0',\
'0',\
'0',\
'0',\
'0',\
'0')",escname,key);
printf("%s",Query);
mysql_query(Query);
To me is nothing wrong o-0
Re: [MySQL] INSERT INTO help -
MP2 - 30.01.2012
You should assign default values to fields instead of setting them in that query.
Re: [MySQL] INSERT INTO help -
[HiC]TheKiller - 30.01.2012
You cannot use Alter as a field name in a query like that due to it being used to alter the table. Rename the Alter field to something else.