SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old September 19th, 2002, 01:53 AM
seiya seiya is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NYC, NY, USA
Posts: 45 seiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to seiya
Help with this mysql creation commands... Please...

Hey, I am good enough in php to make a script but still weak in mysql, so if anyone could correct this for me I would really appreciate it. Thanks.

PROBLEM: IT only creates the first and last table which do not have primary keys. When i install I get a message: Multiple primary key. Multiple Primary Key.... and so on like 6 times.
I just added the unique key field but i dont think it will help, i havent been able to test it, my server went down for some time, i will test it tomorrow, but if you can help me telling me what exactly it is... thanks in advance:

CODE:

mysql_db_query (DB_NAME, "
create table ".DB_PREFIX."writers (
username varchar(16) primary key,
password varchar(16) not null,
full_name text,
email text
)
");

echo mysql_error($connection);

mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."reviews (
rid int primary key auto_increment,
writer varchar(16) NOT NULL, # foreign key writers.username
review text NOT NULL ,
title text NOT NULL ,
developer text NOT NULL ,
publisher text NOT NULL ,
genre text NOT NULL ,
release_date text NOT NULL ,
esrb text NOT NULL ,
rating_graphics text NOT NULL ,
rating_sound text NOT NULL ,
rating_gameplay text NOT NULL ,
rating_rvalue text NOT NULL ,
rating_overall text NOT NULL ,
players text NOT NULL ,
created int ,
modified int ,
published int ,
PRIMARY KEY (rid),
UNIQUE KEY rid (rid)
)
");

echo mysql_error($connection);

mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."previews (
pid int primary key auto_increment,
writer varchar(16) NOT NULL, # foreign key writers.username
preview text NOT NULL ,
title text NOT NULL ,
facts text NOT NULL ,
created int ,
modified int ,
published int ,
PRIMARY KEY (pid) ,
UNIQUE KEY pid (pid)
)
");

echo mysql_error($connection);

mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."features (
fid int primary key auto_increment,
writer varchar(16) NOT NULL, # foreign key writers.username
feature text NOT NULL ,
title text NOT NULL ,
created int ,
modified int ,
published int ,
PRIMARY KEY (fid) ,
UNIQUE KEY fid (fid)
)
");

echo mysql_error($connection);

mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."screens (
sid int primary key auto_increment,
screens text NOT NULL ,
title text NOT NULL ,
totalnumber text NOT NULL ,
created int ,
modified int ,
published int ,
PRIMARY KEY (sid) ,
UNIQUE KEY rid (sid)
)
");

echo mysql_error($connection);


mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."news (
nid int(11) primary key NOT NULL auto_increment,
writer varchar(16) NOT NULL, # foreign key writers.username
headline longtext NOT NULL ,
summary longtext NOT NULL ,
story text NOT NULL ,
picture text NOT NULL ,
date date NOT NULL default '0000-00-00',
PRIMARY KEY (nid) ,
UNIQUE KEY nid (nid)
)
");

echo mysql_error($connection);

mysql_db_query (DB_NAME, "

create table ".DB_PREFIX."newscomments (
newscid int(11) NOT NULL default '0' ,
name text NOT NULL ,
email text NOT NULL ,
content longtext NOT NULL ,
date date NOT NULL default '0000-00-00'
)
");

echo mysql_error($connection);

if (!mysql_error($connection)) echo "<BR>If you did not get any errors then the installation has been completed successfully, <a href='admin'>click here</a> to go to the admin.<BR>";

Reply With Quote
  #2  
Old September 19th, 2002, 03:47 AM
blazin blazin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Aurora, CO, USA
Posts: 24 blazin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to blazin Send a message via AIM to blazin
RE: Help with this mysql creation commands... Please...

It looks like in your create table statements, you are specifying a primary key 2 times. For instance:

Quote:
create table ".DB_PREFIX."previews (
pid int primary key auto_increment,
writer varchar(16) NOT NULL, # foreign key writers.username
preview text NOT NULL ,
title text NOT NULL ,
facts text NOT NULL ,
created int ,
modified int ,
published int ,
PRIMARY KEY (pid) ,
UNIQUE KEY pid (pid)
)


You specify that pid is a primary key on the line
Quote:
pid int primary key auto_increment,

and then again at the bottom. You only need to do it one time. You could remove the "primary key" from the line where you declare the field, or remove it from the end.

If you want to declare a multi-field primary key, you'll need to do that at the end, but single field primary keys can be done on the same line as the field is declared.

Hope this helps.

Dave

Reply With Quote
  #3  
Old September 19th, 2002, 05:22 PM
seiya seiya is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NYC, NY, USA
Posts: 45 seiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to seiya
RE: Help with this mysql creation commands... Please...

Thanks, I did not notice that... =/ Next time i should be more careful...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Help with this mysql creation commands... Please...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway