|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
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>"; |
|
#2
|
||||
|
||||
|
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:
You specify that pid is a primary key on the line Quote:
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 |
|
#3
|
|||
|
|||
|
RE: Help with this mysql creation commands... Please...
Thanks, I did not notice that... =/ Next time i should be more careful...
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Help with this mysql creation commands... Please... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|