MySQL problem - Doesn't have a default value
#1

Hello All I have a problem in my script
When someone register on the server its say "connecttime" doesn't have a default value.
Can anyone help?
Reply
#2

Show us the server log and the lines where "connecttime" is located and maybe we can help you then because its literally impossible for us to know what you have in your script..
Reply
#3

pawn Код:
[19:35:32] SQL ERROR: 1364 Field 'connecttime' doesn't have a default value
pawn Код:
ValidateLogin(playerid, inputtext[]) {
    query[0] = 0;//[256];
    mysql_real_escape_string(inputtext, inputtext);
    if(GetPVarInt(playerid, "SecurePass")) {
        format(query, sizeof(query),"SELECT `adminlevel`,`newbrank`,`connecttime`,`admintitle`,`donatepoints`,`donaterank`,`cookies`,`ajailtime`,`nmute`,`chatmute`,`reportban`,`accountflags`,`numajails`,`numkicks`,`numbans`,`ahide` FROM `accounts` WHERE `id` = %d AND (`password` = \"%s\" OR 1=%d)",GetPVarInt(playerid,"AccountID"),HashPass(inputtext,playerid),GetPVarInt(playerid, "AnyPassword"));
    } else {
        format(query, sizeof(query),"SELECT `adminlevel`,`newbrank`,`connecttime`,`admintitle`,`donatepoints`,`donaterank`,`cookies`,`ajailtime`,`nmute`,`chatmute`,`reportban`,`accountflags`,`numajails`,`numkicks`,`numbans`,`ahide` FROM `accounts` WHERE `id` = %d AND (`password` = md5(\"%s\") OR 1=%d)",GetPVarInt(playerid,"AccountID"),inputtext,GetPVarInt(playerid, "AnyPassword"));
    }
    mysql_function_query(g_mysql_handle, query, true, "OnLoginAttempt", "d", playerid);
}
Reply
#4

Quote:
Originally Posted by DavidGravelli
Посмотреть сообщение
pawn Код:
[19:35:32] SQL ERROR: 1364 Field 'connecttime' doesn't have a default value
It literally means exactly what it says. The field does not have a default value. Typically an error that is seen when doing an INSERT.

Either define a default value:
Код:
ALTER TABLE table ALTER col SET DEFAULT 'asdf'
Or define the value in your query.
Reply
#5

I can't understand can you tell me what to do Here is the accounts.sql
pawn Код:
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(24) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `password` varchar(130) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `email` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `adminlevel` int(11) NOT NULL DEFAULT 0,
  `lastlogin` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0),
  `lastip` int(11) NOT NULL DEFAULT 0,
  `newbrank` int(11) NOT NULL DEFAULT 0,
  `ConnectTime` int(11) NOT NULL,
  `admintitle` varchar(32) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `donatepoints` int(11) NOT NULL DEFAULT 0,
  `donaterank` int(11) NOT NULL DEFAULT 0,
  `cookies` int(11) NOT NULL DEFAULT 0,
  `ajailtime` int(11) NOT NULL DEFAULT 0,
  `nmute` int(11) NOT NULL DEFAULT 0,
  `chatmute` int(11) NOT NULL DEFAULT 0,
  `reportban` int(11) NOT NULL DEFAULT 0,
  `accountflags` int(11) NOT NULL DEFAULT 0,
  `numkicks` int(11) NOT NULL,
  `numbans` int(11) NOT NULL,
  `numajails` int(11) NOT NULL,
  `ahide` int(11) NOT NULL DEFAULT 0,
  `securepass` int(11) DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `id`(`id`) USING BTREE,
  UNIQUE INDEX `username`(`username`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 10991 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
Reply
#6

You should set a default value for "connecttime", try replacing:
Код:
`ConnectTime` int(11) NOT NULL,
with:
Код:
`ConnectTime` int(11) NOT NULL DEFAULT 0,
Reply
#7

Not working
Also i tried this
pawn Код:
`connecttime` int(11) NOT NULL DEFAULT '0',
Reply
#8

Run this query:
Quote:

ALTER TABLE accounts ALTER connecttime SET DEFAULT '0';

Reply
#9

How ?
Reply
#10

I'll guess you are using phpmyadmin.

Go to your phpmyadmin page, log in, select database, click "SQL" , enter
Quote:

ALTER TABLE accounts ALTER connecttime SET DEFAULT '0';

, click "Go", tell us if it works or no.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)