Firefog
Firefog

Reputation: 3174

How to solve Data truncated for column issue

It works on localhost but not in cpanel How can I get rid from this error-

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'connectionMethod' at row 1

here is the MySQL code to create the table:

DROP TABLE IF EXISTS `file_server`;
CREATE TABLE `file_server` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `serverLabel` varchar(100) NOT NULL,
  `serverType` enum('remote','local') DEFAULT NULL,
  `ipAddress` varchar(15) NOT NULL,
  `connectionMethod` enum('ftp') NOT NULL DEFAULT 'ftp',
  `ftpPort` int(11) NOT NULL DEFAULT '21',
  `ftpUsername` varchar(50) NOT NULL,
  `ftpPassword` varchar(50) DEFAULT NULL,
  `statusId` int(11) NOT NULL DEFAULT '1',
  `storagePath` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `statusId` (`statusId`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

Full Database

Upvotes: 3

Views: 46556

Answers (2)

Blank
Blank

Reputation: 12378

Try to change (line 1298 in your script)

`INSERT INTO `file_server` VALUES ('1', 'Local Default', 'local', '', '', '0', '', null, '2', null);`

to

`INSERT INTO `file_server` VALUES ('1', 'Local Default', 'local', '', 'ftp', '0', '', null, '2', null);`

One more thing if your column name is enum then in that case if u also have specified the default value then you need not to specify or give that column any values.

Upvotes: 4

Aarush Aggarwal
Aarush Aggarwal

Reputation: 143

In this case you need to change the query as follow:-

INSERT INTO `file_server` (`serverLabel`,`serverType`,`ipAddress`,`ftpPort`,`ftpUsername`,`ftpPassword`,`statusId`,`storagePath`) VALUES ('Local Default', 'local', '', '0', '', null, '2', null);

OR

If you need to insert values in all the columns then in that case you need to write the below query.

INSERT INTO `file_server` VALUES ('6', 'Local Default', 'local', '', 'ftp', '0', '', NULL, '2', NULL);

Upvotes: 2

Related Questions