Question:
What wrong with the way that I created the event table I keep getting an error message for XAMMP mysql.?
David M
2011-07-19 21:06:59 UTC
CREATE TABLE Event(
Id SERIAL PRIMARY KEY ,
Title VARCHAR( 20 ) NOT NULL ,
Date DATE NOT NULL ,
EventCreator VARCHAR REFERENCES User( Username ) ,


here's my whole table

___________________________________________
CREATE TABLE Users (
Username VARCHAR(20) PRIMARY KEY,
PASSWORD VARCHAR(12) NOT NULL,
First VARCHAR(26) NOT NULL,
Middle VARCHAR(26),
Last VARCHAR(26) NOT NULL
);

CREATE TABLE Event (
Id SERIAL PRIMARY KEY,
Title VARCHAR(20) NOT NULL,
Date DATE NOT NULL,
EventCreator VARCHAR REFERENCES User(Username),
TIME NOT NULL

);

CREATE TABLE Invitation (
Id SERIAL PRIMARY KEY,
Descript VARCHAR(20) NOT NULL,
Invited VARCHHAR(20) REFERENCES Users(Username),
EventId INTEGER(20) REFERENCES Event(Id),
Response VARCHAR(14) DEFAULT 'No Answer' CHECK( Response='Yes' OR Response='No' OR Response='Maybe' OR Response='No Answer')

);


CREATE TABLE Emails (
Id VARCHAR(20) REFERENCES Users(Username),
Email VARCHAR(20) NOT NULL,
CONSTRAINT Em_PK PRIMARY KEY (Id, Email)
);


TIME NOT NULL
);


MySQL said: Documentation
#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 'REFERENCES User(Username),
TIME NOT NULL

)' at line 5
Three answers:
just "JR"
2011-07-19 23:43:20 UTC
Invited VARC HH AR(20) REFERENCES Users(Username),

Two H's!
trif
2016-12-10 09:52:11 UTC
hi guy, it somewhat is annoying to verify the priority such as your database because of the fact your Hypertext Preprocessor fact do 2 projects (a million) connect with the MYSQL Server with account ($consumer) and pwd ($password) (2) pick to the database ($database). it is going to be extra suitable by employing changing --------------------------------------... $cxn = mysqli_connect ($host, $consumer, $password, $database) or die ( "ought to no longer connect with server" ); --------------------------------------... by employing 2 declarations: ------------------------------- $cnx=@mysql_connect($host, $consumer, $password); if (!$cnx) //If can not connect with MySQL Server go out('ought to no longer connect with server'); //waiting to hook up with MySQL Server and start to pick //database if (!@mysql_select_db($database)) //If some thing //incorrect with the database go out('Please verify back database'); and alter the final fact to: mysqli_query($cnx,"INSERT INTO time-honored (user_name, zip, month, day, email_address, password, question, answer, comments) VALUES ('$user_name', '$zip', '$month', '$day', '$email_address', '$password', '$question', '$answer', '$comments')"); because of the fact mysqli_query demands 2 parameters: first one is the connect with the database (by employing potential of $cnx). on your fact, you do no longer provide it.
sandman
2011-07-19 22:08:49 UTC
REFERENCES User(Username) maybe has to be without the , or needs some special mark after it. like ; maybe its something small and i dont know exactly what either.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...