skip to Main Content

I have done the Setup database in localhost PHPMyadmin.
when I submit a form via PHP it throw error like please enter valid length
What is the problem with this query?
Please look into the query and help.

    CREATE TABLE `test`.`test`
  (
     `id`          INT NOT NULL auto_increment,
     `oname`       VARCHAR(50) NOT NULL,
     `cname`       VARCHAR NOT NULL,
     `cphone`      VARCHAR NOT NULL,
     `cemail`      VARCHAR NOT NULL,
     `tplot`       VARCHAR NOT NULL,
     `registerno`  VARCHAR NOT NULL,
     `registerdoc` TEXT NOT NULL,
     `tpscheme`    INT NOT NULL,
     `tpnumber`    INT NOT NULL,
     `spnumber`    INT NOT NULL,
     `area`        VARCHAR NOT NULL,
     `plotarea`    INT NOT NULL,
     `direction`   VARCHAR NOT NULL,
     `roads`       VARCHAR NOT NULL,
     `r1w`         VARCHAR NOT NULL,
     `r2w`         VARCHAR NOT NULL,
     `r3w`         VARCHAR NOT NULL,
     `r4w`         VARCHAR NOT NULL,
     `r1d`         VARCHAR NOT NULL,
     `r2d`         VARCHAR NOT NULL,
     `r3d`         VARCHAR NOT NULL,
     `r4d`         VARCHAR NOT NULL,
     `zoning`      INT NOT NULL,
     `zoningdoc`   INT NOT NULL,
     `benefit`     VARCHAR NOT NULL,
     `natureplot`  VARCHAR NOT NULL,
     `deduction`   VARCHAR NOT NULL,
     `howmuch`     INT NOT NULL,
     `allsidedoc`  VARCHAR NOT NULL,
     `diagonaldoc` VARCHAR NOT NULL,
     `totalmem`    INT NOT NULL,
     `flatgiven`   INT NOT NULL,
     `fun`         VARCHAR NOT NULL,
     `fun`         VARCHAR NOT NULL,
     PRIMARY KEY (`id`)
  )
engine = innodb; 

2

Answers


  1. The max length of a VARCHAR is not dynamic, it is fixed and therefore has to be specified.
    http://sqlines.com/mysql/datatypes/varchar

    Login or Signup to reply.
  2. You must assign a length to varchar datatype eg: VARCHAR(255)

    CREATE TABLE `mainland`.`mainland1` ( 
        `id` INT NOT NULL AUTO_INCREMENT , 
        `oname` VARCHAR(50) NOT NULL , 
        `cname` VARCHAR(255) NOT NULL , 
        `cphone` VARCHAR(255) NOT NULL , 
        `cemail` VARCHAR(255) NOT NULL , 
        `tplot` VARCHAR(255) NOT NULL , 
        `registerno` VARCHAR(255) NOT NULL , 
        `registerdoc` TEXT NOT NULL , 
        `tpscheme` INT NOT NULL , 
        `tpnumber` INT NOT NULL , 
        `spnumber` INT NOT NULL , 
        `area` VARCHAR(255) NOT NULL , 
        `plotarea` INT NOT NULL , 
        `direction` VARCHAR(255) NOT NULL , 
        `roads` VARCHAR(255) NOT NULL , 
        `r1w` VARCHAR(255) NOT NULL , 
        `r2w` VARCHAR(255) NOT NULL , 
        `r3w` VARCHAR(255) NOT NULL , 
        `r4w` VARCHAR(255) NOT NULL , 
        `r1d` VARCHAR(255) NOT NULL , 
        `r2d` VARCHAR(255) NOT NULL , 
        `r3d` VARCHAR(255) NOT NULL , 
        `r4d` VARCHAR(255) NOT NULL , 
        `zoning` INT NOT NULL , 
        `zoningdoc` INT NOT NULL , 
        `benefit` VARCHAR(255) NOT NULL , 
        `natureplot` VARCHAR(255) NOT NULL , 
        `deduction` VARCHAR(255) NOT NULL , 
        `howmuch` INT NOT NULL , 
        `allsidedoc` VARCHAR(255) NOT NULL , 
        `diagonaldoc` VARCHAR(255) NOT NULL , 
        `totalmem` INT NOT NULL ,
         `flatgiven` INT NOT NULL , 
         `fun` VARCHAR(255) NOT NULL , 
         `fun` VARCHAR(255) NOT NULL , 
         PRIMARY KEY (`id`)) ENGINE = InnoDB;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search