Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    483
    Member #
    17875
    Liked
    1 times
    After creating these two tables, it still lets me insert into the user table with an invalid roleID. Not sure why this isnt working.
    Code:
    CREATE TABLE role
    (
     `roleID` INT AUTO_INCREMENT,
     `roleName` TEXT NOT NULL, 
     PRIMARY KEY (`roleID`) 
    )
    CREATE TABLE user
    (
     `userID` INT AUTO_INCREMENT,
     `userName` VARCHAR(12) UNIQUE,
     `userPass` VARCHAR(12) NOT NULL ,
     `roleID` INT(3) NOT NULL ,
     `userFirst` TEXT NOT NULL ,
     `userLast` TEXT NOT NULL ,
     `userEmail` VARCHAR(50) UNIQUE NOT NULL, 
     PRIMARY KEY (`userID`), 
     CONSTRAINT user_roleFK FOREIGN KEY (roleID) REFERENCES role(roleID) 
    )
    INSERT INTO role (roleID, roleName) VALUES ('', 'Patient');
    INSERT INTO role (roleID, roleName) VALUES ('', 'Clinician');
    INSERT INTO role (roleID, roleName) VALUES ('', 'IT');
    //This should throw an error but doesnt
    INSERT INTO user (userID,userFirst,userLast,userEmail,userPass,roleID) 
    VALUES ('', 'test', 'test', 'test@test.ca, 'itstaff', 9);
    Help would be appreciated
    Thanks
    =)

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:58 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com