SA-MP Forums Archive
MySQL error - 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)
+--- Thread: MySQL error (/showthread.php?tid=674599)



MySQL error - PemburuHantu - 23.04.2020

some player in my server his stats is not saved,, and im trying to register new account and it same,, my new account not saved.. anyone can help me? im using MySQL
HTML Code:
 error #1364 while executing query "INSERT INTO `playerbase` (`name`, `pass`, `ip`, `adminlvl`, `vip`, `money`, `medkit` ,`armourpack`, `score`,`inclan`,`clanlead`,`clanown`,`ddm`,`dcbdm`,`dsdm`,`head`, `dmusickit`,`clancoown`,`classes`,`XP`,`VPB`) VALUES ('sdbasadf','EE795A523A9E1F36301C39B20CFA4F25098880CE24AC04BDB8DAE892C3F79622F6E417A9BD4EAE0DF60EDCE88D869583F8A6A9E474CC1BE46DAF4B4039B6459A', '116.71.4.44', 0, 0, 0, 0, 0, 0,-1,-1,-1,0,0,0,0,0,-1,'00000000000000000000',0,0)": Field 'spvip' doesn't have a default value



Re: MySQL error - NeamPojma - 23.04.2020

Do you have closing " quotes?


Re: MySQL error - PemburuHantu - 23.04.2020

Quote:
Originally Posted by NeamPojma
View Post
Do you have closing " quotes?
yes, check the error code
my register code
HTML Code:
		case 126:
		{
			new string[200];
                        new nam[24]; format(nam, 24, PlayerInfo[playerid][Nick]);
			if(!response)
			{

				format(string, sizeof(string),""cwhite"Welcome {0080FF}%s "cwhite"you are already registered\nKindly enter password to {0080FF}login"cwhite" to your account\n"cred"Please Register", nam);
				return ShowPlayerDialogEx(playerid, 126, DIALOG_STYLE_INPUT, "Register",string,"Register","");
			}
			        if (strlen(inputtext) < 4 || strlen(inputtext) > 20) {
				format(string, sizeof(string),""cwhite"Welcome {0080FF}%s "cwhite"you are already registered\nKindly enter password to {0080FF}login"cwhite" to your account\n"cred"Too short or Too long Password", nam);
				return ShowPlayerDialogEx(playerid, 126, DIALOG_STYLE_INPUT, "Register",string,"Register","");
			}
			new query[505];
			WP_Hash(PlayerInfo[playerid][Pass], 129, inputtext);
			mysql_format(mysql, query, sizeof(query), "INSERT INTO `playerbase` (`name`, `pass`, `ip`, `adminlvl`, `vip`, `money`, `medkit` ,`armourpack`, `score`,`inclan`,`clanlead`,`clanown`,`ddm`,`dcbdm`,`dsdm`,`head`, `dmusickit`,`clancoown`,`classes`,`XP`,`VPB`) VALUES ('%e','%s', '%s', 0, 0, 0, 0, 0, 0,-1,-1,-1,0,0,0,0,0,-1,'00000000000000000000',0,0)", nam,PlayerInfo[playerid][Pass],PlayerInfo[playerid][lastip]);
			mysql_tquery(mysql, query, "OnAccountRegister", "di", playerid, rCheck[playerid]);
			PlayerInfo[playerid][LoggedIn] = true;
			GiveCash(playerid,100000);
			SetPlayerScore(playerid,15);
			SendClientMessage(playerid, -1, "*You are {0080FF}registered {FFFFFF}and logged in");
			PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		}



Re: MySQL error - SiaReyes - 23.04.2020

Field 'spvip', SET default value as 0.

Example:
Code:
`spvip` mediumint(2) NOT NULL DEFAULT 0,



Re: MySQL error - PemburuHantu - 23.04.2020

Quote:
Originally Posted by SiaReyes
View Post
Field 'spvip', SET default value as 0.

Example:
Code:
`spvip` mediumint(2) NOT NULL DEFAULT 0,
how to do it?


Re: MySQL error - PemburuHantu - 25.04.2020

anyone can help me?


Re: MySQL error - SiaReyes - 25.04.2020

Code:
Alter Table `playerbase`
MODIFY `spvip` mediumint(2) NOT NULL DEFAULT 0;
run this query in SQL Tab in phpmyadmin


Re: MySQL error - ShadowMortar - 25.04.2020

Or perhaps, do not use WAMP SERVER, use XAMPP.


Re: MySQL error - Kent - 25.04.2020

Update your table. Follow what Sia said to assign a DEFAULT value to spvip.


Re: MySQL error - Kwarde - 25.04.2020

See indeed Sia's answer. To explain it a bit futher:

Quote:

Field 'spvip' doesn't have a default value

You didn't specify this column in the INSERT query. When you don't, the server requires a default value to be set if it also may not be empty (NOT NULL).
Look at this table:
Code:
CREATE TABLE test(
    Foo INT NOT NULL,
    Required INT NOT NULL DEFAULT 1,
    Bar INT DEFAULT 5,
    Not_Required INT,
    spvip MEDIUMINT(2) NOT NULL
);
When using the INSERT query:
- You must provide a value for Foo: It may not be null and has no default value.
- You don't have to provide a value for Required: It may not be null but it has a default value. Not specifying Required in an INSERT statement will set it's value to 1
- You don't have to provide a value for Bar. It may be null. If you don't specify it, it will be set to 5.
- You don't have to provide a value for Not_Required. It may be null and it doesn't have a default value. When not specyfing one it will be empty (NULL)
- You must provide a value for spvip. It may not be null and has no default value.

Thus using this query would be valid:
Code:
INSERT INTO test (Foo, spvip) VALUES (10, 0);
This query would return the error you're currently getting, because spvip has no default value and also is required to have a value:
Code:
INSERT INTO test (Foo, Required, Bar, Not_Required) VALUES (10, 0, 6, NULL);
I hope that clears things up a bit more.