SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/04/2020, 01:01 AM   #1
PemburuHantu
Big Clucker
 
PemburuHantu's Avatar
 
Join Date: May 2019
Location: Indonesia ( Gorontalo )
Posts: 86
Reputation: 0
Default MySQL error

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
__________________
SWAT VS TERRORIST [TDM]
35.228.221.171:7777

Last edited by PemburuHantu; 23/04/2020 at 01:45 AM.
PemburuHantu is offline   Reply With Quote
Old 23/04/2020, 01:43 AM   #2
NeamPojma
Big Clucker
 
Join Date: Jan 2015
Location: Serbia
Posts: 72
Reputation: 10
Default Re: MySQL error

Do you have closing " quotes?
NeamPojma is offline   Reply With Quote
Old 23/04/2020, 02:10 AM   #3
PemburuHantu
Big Clucker
 
PemburuHantu's Avatar
 
Join Date: May 2019
Location: Indonesia ( Gorontalo )
Posts: 86
Reputation: 0
Default Re: MySQL error

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);
		}
__________________
SWAT VS TERRORIST [TDM]
35.228.221.171:7777
PemburuHantu is offline   Reply With Quote
Old 23/04/2020, 04:23 AM   #4
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: MySQL error

Field 'spvip', SET default value as 0.

Example:
Code:
`spvip` mediumint(2) NOT NULL DEFAULT 0,
SiaReyes is offline   Reply With Quote
Old 23/04/2020, 05:50 AM   #5
PemburuHantu
Big Clucker
 
PemburuHantu's Avatar
 
Join Date: May 2019
Location: Indonesia ( Gorontalo )
Posts: 86
Reputation: 0
Default Re: MySQL error

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?
__________________
SWAT VS TERRORIST [TDM]
35.228.221.171:7777
PemburuHantu is offline   Reply With Quote
Old 25/04/2020, 01:49 AM   #6
PemburuHantu
Big Clucker
 
PemburuHantu's Avatar
 
Join Date: May 2019
Location: Indonesia ( Gorontalo )
Posts: 86
Reputation: 0
Default Re: MySQL error

anyone can help me?
__________________
SWAT VS TERRORIST [TDM]
35.228.221.171:7777
PemburuHantu is offline   Reply With Quote
Old 25/04/2020, 01:52 AM   #7
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: MySQL error

Code:
Alter Table `playerbase`
MODIFY `spvip` mediumint(2) NOT NULL DEFAULT 0;
run this query in SQL Tab in phpmyadmin
SiaReyes is offline   Reply With Quote
Old 25/04/2020, 07:47 AM   #8
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 303
Reputation: 89
Default Re: MySQL error

Or perhaps, do not use WAMP SERVER, use XAMPP.
__________________
If you appreciate(d) my help, I will appreciate +REP .

Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar is offline   Reply With Quote
Old 25/04/2020, 11:41 AM   #9
Kent
Big Clucker
 
Kent's Avatar
 
Join Date: Feb 2020
Location: Philippines
Posts: 64
Reputation: 2
Default Re: MySQL error

Update your table. Follow what Sia said to assign a DEFAULT value to spvip.
__________________
Lawless Roleplay
Where Lunatics Prosper!
samp.lawlessrp.com
Kent is offline   Reply With Quote
Old 25/04/2020, 02:57 PM   #10
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,740
Reputation: 1686
Default Re: MySQL error

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.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to you lulo356 Scripting Help 3 24/07/2015 05:58 AM
(error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for t SandKing94 Scripting Help 3 22/05/2015 08:53 AM
[MYSQL ERROR ] Access denied for user 'your username here'@'localhost' (using password: YES) (error ID: 1045). SpikY_ Scripting Help 3 07/11/2014 04:09 PM
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
Mysql queriesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th audriuxxx Scripting Help 4 11/04/2014 06:42 PM


All times are GMT. The time now is 05:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.