Jump to content

[SOLVED] Trouble with Mysql


486974

Recommended Posts

Hi i am using a tutorial on membership site (php freaks) have followed what they put in the columns and come up with errors saying i cant have not null with text i tried changing it to null but got the same error message

 

Error

SQL query:

 

CREATE TABLE `members` (

 

`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`username` VARCHAR( 15 ) NOT NULL ,

`encryptpass` VARCHAR( 255 ) NOT NULL ,

`password` VARCHAR( 15 ) NOT NULL ,

`name` VARCHAR( 255 ) NOT NULL ,

`prov` ENUM NOT NULL ,

`style` TINYTEXT NOT NULL ,

`hist` TEXT NOT NULL ,

`open` TEXT NOT NULL ,

`webs` VARCHAR( 255 ) NOT NULL DEFAULT '"http://"',

`email` VARCHAR( 255 ) NOT NULL ,

`photo` VARCHAR( 255 ) NOT NULL DEFAULT '"nopic.jpg"',

`signupdate` DATETIME NOT NULL DEFAULT '"now()"',

UNIQUE (

`username`

)

) 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, `style` TINYTEXT NOT NULL, `hist` TEXT NOT NULL, `open` TEXT NOT NULL,' at line 1

 

Please help

Rob

Link to comment
Share on other sites

The ENUM is wrong

 

try this

 CREATE TABLE `members` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 15 ) NOT NULL ,
`encryptpass` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 15 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`prov` ENUM('small', 'medium', 'large') NOT NULL ,
`style` TINYTEXT NOT NULL ,
`hist` TEXT NOT NULL ,
`open` TEXT NOT NULL ,
`webs` VARCHAR( 255 ) NOT NULL DEFAULT 'http://',
`email` VARCHAR( 255 ) NOT NULL ,
`photo` VARCHAR( 255 ) NOT NULL DEFAULT 'nopic.jpg',
`signupdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM 

 

Note: update the prov (ENUM) to the correct data

i also updated the `signupdate` & the ID

Link to comment
Share on other sites

I am still getting the same error

 

Error

SQL query:

 

CREATE TABLE `members` (

 

`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`username` VARCHAR( 15 ) NOT NULL ,

`encryptpass` VARCHAR( 255 ) NOT NULL ,

`password` VARCHAR( 15 ) NOT NULL ,

`name` VARCHAR( 255 ) NOT NULL ,

`prov` ENUM NOT NULL COMMENT '(''small'', ''medium'', ''large'')',

`style` TINYTEXT NOT NULL ,

`hist` TEXT NOT NULL ,

`open` TEXT NOT NULL ,

`webs` VARCHAR( 255 ) NOT NULL DEFAULT '"http://"',

`email` VARCHAR( 255 ) NOT NULL ,

`photo` VARCHAR( 255 ) NOT NULL DEFAULT '"nopic.jpg"',

`signupdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,

UNIQUE (

`username`

)

) 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 COMMENT '(''small'', ''medium'', ''large'')', `style` TINYTEXT NOT NULL' at line 1

 

 

Link to comment
Share on other sites

You must have copied it wrong because i copied what you just pout and got error but when i copy madtechies it works

 

thas works for me

 

 CREATE TABLE `members` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 15 ) NOT NULL ,
`encryptpass` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 15 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`prov` ENUM('small', 'medium', 'large') NOT NULL ,
`style` TINYTEXT NOT NULL ,
`hist` TEXT NOT NULL ,
`open` TEXT NOT NULL ,
`webs` VARCHAR( 255 ) NOT NULL DEFAULT 'http://',
`email` VARCHAR( 255 ) NOT NULL ,
`photo` VARCHAR( 255 ) NOT NULL DEFAULT 'nopic.jpg',
`signupdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM 

 

 

 

you added

 

UNIQUE (

`username`

)

 

 

Liam

 

Link to comment
Share on other sites

Thats what php admin produced isnt that the same as yours i dont understand what i have done wrong

 

CREATE TABLE `members` (

 

`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`username` VARCHAR( 15 ) NOT NULL ,

`encryptpass` VARCHAR( 255 ) NOT NULL ,

`password` VARCHAR( 15 ) NOT NULL ,

`name` VARCHAR( 255 ) NOT NULL ,

`prov` ENUM NOT NULL COMMENT '("small", "medium", "large")',

`style` TINYTEXT NOT NULL ,

`hist` TEXT NOT NULL ,

`open` TEXT NOT NULL ,

`webs` VARCHAR( 255 ) NOT NULL DEFAULT '"http://"',

`email` VARCHAR( 255 ) NOT NULL ,

`photo` VARCHAR( 255 ) NOT NULL DEFAULT '"nopic.jpg"',

`signupdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

) 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 COMMENT '("small", "medium", "large")', `style` TINYTEXT NOT NULL, `his' at line 1

 

 

Link to comment
Share on other sites

POST the EXACT code i have below in PMA's SQL section it should work.. i'll note again the ENUM('small', 'medium', 'large') was made up.. this will need to be changed to suite

ie

ENUM('UK', 'US', 'Europe')

or whatever its used for..

 

the reason yours failed it because you tried to add the list in to the comments..!

 

 

The ENUM is wrong

 

try this

 CREATE TABLE `members` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 15 ) NOT NULL ,
`encryptpass` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 15 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`prov` ENUM('small', 'medium', 'large') NOT NULL ,
`style` TINYTEXT NOT NULL ,
`hist` TEXT NOT NULL ,
`open` TEXT NOT NULL ,
`webs` VARCHAR( 255 ) NOT NULL DEFAULT 'http://',
`email` VARCHAR( 255 ) NOT NULL ,
`photo` VARCHAR( 255 ) NOT NULL DEFAULT 'nopic.jpg',
`signupdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM 

 

Note: update the prov (ENUM) to the correct data

i also updated the `signupdate` & the ID

Link to comment
Share on other sites

Extra Info..

 

your need to change the prov later so..

via PMA, select the prov field and click edit (change), Now in the length/value will appear as

'small','medium','large'

change to what you need ie

'US','UK','Europe','Blar','etc'

 

Hope all goes well, if you have more problems include a link to the tutorial so we can see what "should" happen

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.