AcidDriver Posted July 16, 2008 Share Posted July 16, 2008 SQL query: CREATE TABLE `hope` ( `lname` TEXT NOT NULL , `fname` TEXT NOT NULL , `idnum` INT NOT NULL , `gradyear` INT NOT NULL , `donor` ENUM NOT NULL , `foh` ENUM NOT NULL , `org` TEXT NOT NULL , `fellow` ENUM NOT NULL , `sfellow` ENUM NOT NULL , `scholar` ENUM NOT NULL , `lreduce` ENUM NOT NULL , `address` TEXT NOT NULL , `city` TEXT NOT NULL , `state` TEXT NOT NULL , `zip` TEXT NOT NULL , `phone` TEXT NOT NULL , `waddress` TEXT NOT NULL , `wcity` TEXT NOT NULL , `wstate` TEXT NOT NULL , `wzip` TEXT NOT NULL , `wphone` TEXT NOT NULL , `fax` TEXT NOT NULL , `cphone` TEXT NOT NULL , `email` TEXT NOT NULL , `interests` ENUM NOT NULL , `project` ENUM NOT NULL , `liason` ENUM NOT NULL , `pliason` ENUM NOT NULL , `comtotalhours` INT NOT NULL , `comagency` TEXT NOT NULL , `comdate` TEXT NOT NULL , `comhours` INT NOT NULL , `adtotalhours` INT NOT NULL , `adagency` TEXT NOT NULL , `addate` TEXT NOT NULL , `adhours` INT NOT NULL , `adattorney` TEXT NOT NULL , `adattorneycon` TEXT NOT NULL , `userlanguage` ENUM NOT NULL ) ENGINE = MYISAM MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL, `foh` ENUM NOT NULL, `org` TEXT NOT NULL, `fellow` ENUM NOT NULL, `sfe' at line 1 Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 i am using phpmyadmin, by the way Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 16, 2008 Share Posted July 16, 2008 Data types such as INT and ENUM must have a length/value set, eg INT(11) or ENUM('option1','option2') PHPMyAdmin provides a length/value field. What is the purpose of the hope table? Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 this is a databse table for a school project. I am creating it with phpmyadmin, so i guess to do those lengths, i input it in....lengths. the obvious is so easily missed. Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 I assigned variables, and got this. CREATE TABLE `hope` ( `lname` TEXT NOT NULL , `fname` TEXT NOT NULL , `idnum` INT( 10 ) NOT NULL , `gradyear` INT( 4 ) NOT NULL , `donor` ENUM( 1 ) NOT NULL , `foh` ENUM( 1 ) NOT NULL , `org` TEXT NOT NULL , `fellow` ENUM( 1 ) NOT NULL , `sfellow` ENUM( 1 ) NOT NULL , `scholar` ENUM( 1 ) NOT NULL , `lreduce` ENUM( 1 ) NOT NULL , `address` TEXT NOT NULL , `city` TEXT NOT NULL , `state` TEXT NOT NULL , `zip` TEXT NOT NULL , `phone` TEXT NOT NULL , `waddress` TEXT NOT NULL , `wcity` TEXT NOT NULL , `wstate` TEXT NOT NULL , `wzip` TEXT NOT NULL , `wphone` TEXT NOT NULL , `fax` TEXT NOT NULL , `cphone` TEXT NOT NULL , `email` TEXT NOT NULL , `interests` ENUM( 1 ) NOT NULL , `project` ENUM( 1 ) NOT NULL , `liason` ENUM( 1 ) NOT NULL , `pliason` ENUM( 1 ) NOT NULL , `comtotalhours` INT( 1000 ) NOT NULL , `comagency` TEXT NOT NULL , `comdate` TEXT NOT NULL , `comhours` INT( 1000 ) NOT NULL , `adtotalhours` INT( 1000 ) NOT NULL , `adagency` TEXT NOT NULL , `addate` TEXT NOT NULL , `adhours` INT( 1000 ) NOT NULL , `adattorney` TEXT NOT NULL , `adattorneycon` TEXT NOT NULL , `userlanguage` ENUM( 3 ) NOT NULL ) ENGINE = MYISAM MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1) NOT NULL, `foh` ENUM(1) NOT NULL, `org` TEXT NOT NULL, `fellow` ENUM(1) NOT N' at line 1 Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 I just read the guidelines, sorry everyone for not adhering to them. MySQL version 5.0.27 I need this table to be created so that the PHP code may communicate with the server. It is not creating a table I have clicked the save button many times, also added the length/values. Thanks in advance Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 16, 2008 Share Posted July 16, 2008 You need to readup on the documentation for the ENUM field, ENUM allows to set certain values that the field excepts, such as 'yes' and 'no' Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 16, 2008 Share Posted July 16, 2008 I believe the enum values need to be in single quotes. So: 1 becomes '1' and if there are more than one, separate by a comma. And for INT, you dont need to specify a length Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 ok, i have looked at the enum docs. so ENUM(0,1) will have the 0 false and 1 true values in it. How do i set that in phpmyAdmin? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 16, 2008 Share Posted July 16, 2008 ok, i have looked at the enum docs. so ENUM(0,1) will have the 0 false and 1 true values in it. How do i set that in phpmyAdmin? no. enum allows you to setup the column so only specified value can go into it. If you want 0 and 1 to be the only values allowed, then you'd do ( '0', '1' ). It has nothing to do with 0 false values and 1 true. You need to think about why you are making the column enumerated. Is it required that the column only be one of a few different choices? If not, just make it a varchar or an int Quote Link to comment Share on other sites More sharing options...
AcidDriver Posted July 16, 2008 Author Share Posted July 16, 2008 Vefore anything further I would like to thank everyone for tagging along with a noob, especially dannyb785. OK, so what I am trying to do with the enum ones is set it so that values from HTML are passed through php to be placed in thge table as true or false. MySQL does not have the boolean type(which would make life easier), so i am thinking of what to do. I thought that using an int with 0 for false, and 1 for true would work, so I would use int, i guess... But what happens in the case where I have PHP passing down something like this: 0 - Agency 1 1 - Agency 2 2 - Agency 3 Mike fulfills 0 and 2, so i pass down 0 and 2 to the table, so it is shown that he belongs to agency 1 and agency 3? Quote Link to comment Share on other sites More sharing options...
fenway Posted July 16, 2008 Share Posted July 16, 2008 You normalize your database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.