Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
dwsddas
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 22, 2009 4:44 am
Post
by dwsddas »
Hi, I have a code to create two tables. And the code does not work. Can you tell me where is wrong. I think that I need to do something with INDEX.
Code: Select all
mysql_query("CREATE TABLE users
(username varchar(15),
PRIMARY KEY (username),
lastname text,
firstname text,
password text)
ENGINE=INNODB;
")
mysql_query("CREATE TABLE textt
(username varchar(15),
textname text,
textbody text,
INDEX (username),
FOREIGN KEY (username) REFERENCES users(username))
ENGINE=INNODB;
")
-
VladSun
- DevNet Master
- Posts: 4313
- Joined: Wed Jun 27, 2007 9:44 am
- Location: Sofia, Bulgaria
Post
by VladSun »
Try
[sql]INDEX IX_username (username)[/sql]
There are 10 types of people in this world, those who understand binary and those who don't
-
dwsddas
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 22, 2009 4:44 am
Post
by dwsddas »
Doesn't work. It shows error message:
Parse error: syntax error, unexpected T_STRING in /home/...
-
Weirdan
- Moderator
- Posts: 5978
- Joined: Mon Nov 03, 2003 6:13 pm
- Location: Odessa, Ukraine
Post
by Weirdan »
You missed semicolons after mysql_query() function calls. It has nothing to do with index or database.