Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z tworzeniem i (chyba) auto_increment
darth_sidious
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 1
Dołączył: 19.12.2005

Ostrzeżenie: (0%)
-----


Witam

"Bawie" sie wlasnie skryptem typerow Prediction League i juz na samym poczatku, podczas instalacji i konfiguracji bazy (MySql) mam juz maly problem. Skrypt instalacyjny tworzy baze a nastepnie tabele potrzebne do dzialania skryptu. Baza tworzy sie bez problemu. Problem pojawil sie przy tworzeniu tabel. Z tego co zauwazylem z tabela, w ktorej primary key nie jest auto_increment nie ma problemu - tworzy sie. Lecz gdy primary key jest auto_increment pojawia sie nastepujacy error:

Query failed: create table pl.pluserdata (lid int not null , userid int not null auto_increment, username varchar(32) not null , password varchar(40), email varchar(60), icon varchar(128), lang varchar(32), usertype smallint, dflths smallint default 0, dfltas smallint default 0, since DATE, isauto enum('Y','N') default 'N', primary key (lid, userid));
Incorrect table definition; there can be only one auto column and it must be defined as a key


Ponizej kod, ktory tworzy tabele, ktorej blad widnieje powyzej:

  1. <?php
  2. $query = "create table $dbname.$dbaseUserData
  3. (lid int not null ,
  4.  userid int not null auto_increment,
  5.  username varchar($userlen) not null ,
  6.  password varchar($passlen),
  7.  email varchar($emaillen),
  8.  icon varchar($fnamelen),
  9.  lang varchar(32),
  10.  usertype smallint,
  11.  dflths smallint default 0,
  12.  dfltas smallint default 0,
  13.  since DATE,
  14.  isauto enum('Y','N') default 'N',
  15.  primary key (lid, userid));";
  16. $userresult = mysql_query($query)
  17. or die("Query failed: $query<br>n".mysql_error());
  18. ?>



A ponizej fragment, ktory nie wywala bleu i poprawnie tworzy tabele:

  1. <?php
  2. $query = "create table $dbname.$dbasePredictionData
  3.  (lid int not null ,
  4. userid int not null,
  5. matchid int not null,
  6. predtime timestamp,
  7. homescore smallint unsigned,
  8. awayscore smallint unsigned,
  9. isauto enum('Y','N') default 'N',
  10. primary key(lid, userid, matchid))";
  11. $userresult = mysql_query($query)
  12. or die("Query failed: $query<br>n".mysql_error());
  13. ?>


Co jest nie tak. Zaznaczam, ze nic sam nie kombinowale - jest to fragment oryginalnego skryptu tworzacego tabele...

Pozdrawiam
Darth
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
jarek26
post
Post #2





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 2.10.2010
Skąd: Łomża

Ostrzeżenie: (0%)
-----


Witam. Mógłby mi ktokolwiek pomóc gdyż mam podobny problem z tym samym skryptem z tym, że jest to nowsza wersja. Po próbie tworzenia tabeli pokazuje się taki błąd
Kod
Query failed: create table fpgpl_typer.pluserdata (lid int not null , userid int not null auto_increment, username varchar(32) not null , password varchar(40), email varchar(60), icon varchar(128), lang varchar(32), usertype smallint, dflths smallint default 0, dfltas smallint default 0, since DATE, auto enum('Y','N') default 'N', primary key (lid,userid));
Incorrect table definition; there can be only one auto column and it must be defined as a key
czyli taki sam jak u osoby która rozpoczęła temat. Teoretycznie jest rozwiązanie lecz on miał inną wersję skryptu a ja mam inną. Moje pytanie brzmi. Gdzie dodać i czy wogóle dodawać wartość
  1.  
  2. <?php
  3. type=myisam
  4. ?>


jeżeli kod do tworzenia tabeli wygląda następująco
  1. if ($createtables == "TRUE") {
  2. $query = "create table $dbname.$dbaseUserData (lid int not null , userid int not null auto_increment, username varchar($userlen) not null , password varchar($passlen), email varchar($emaillen), icon varchar($fnamelen), lang varchar(32), usertype smallint, dflths smallint default 0, dfltas smallint default 0, since DATE, auto enum('Y','N') default 'N', primary key (lid,userid));";
  3. $userresult = mysql_query($query)
  4. or die("Query failed: $query<br>\n".mysql_error());
  5.  
  6.  
  7.  
  8. $query = "create table $dbname.$dbasePredictionData (lid int not null , userid int not null, matchid int not null ,predtime timestamp, homescore smallint unsigned, awayscore smallint unsigned, isauto enum('Y','N') default 'N', primary key(lid, userid, matchid))";
  9. $userresult = mysql_query($query)
  10. or die("Query failed: $query<br>\n".mysql_error());
  11.  
  12. $query = "create table $dbname.$dbaseMatchData (lid int not null, matchid int not null auto_increment, matchdate DATETIME not null, hometeam varchar($teamlen) not null, awayteam varchar($teamlen) not null, homescore smallint unsigned, awayscore smallint unsigned, primary key(lid,matchid));";
  13. $userresult = mysql_query($query)
  14. or die("Query failed: $query<br>\n".mysql_error());
  15.  
  16. $query = "create table $dbname.$dbaseStandings (lid int not null, userid int not null, position smallint not null, pld int unsigned, won int unsigned, drawn int unsigned, lost int unsigned, gfor smallint unsigned, gagainst smallint unsigned, diff smallint, points int unsigned, primary key(lid,userid));";
  17. $userresult = mysql_query($query)
  18. or die("Query failed: $query<br>\n".mysql_error());
  19.  
  20. $query = "create table $dbname.$dbaseConfigData (lid int not null, grp int not null, param varchar(32) not null, value varchar(90) not null, descr text not null, ro enum('Y','N') default 'N', primary key(lid,param));";
  21. $userresult = mysql_query($query)
  22. or die("Query failed: $query<br>\n".mysql_error());
  23.  
  24. $query = "create table $dbname.$dbaseMsgData (lid int not null, msgid int not null auto_increment, threadid int, prevmsg int, sender int not null, receiver int not null, subject varchar(255), body text, status enum(\"new\",\"read\",\"deleted\"), msgtime timestamp, primary key(lid,msgid));";
  25. $userresult = mysql_query($query)
  26. or die("Query failed: $query<br>\n".mysql_error());
  27.  
  28. }


Bardzo proszę o pomoc bo nie potrafię sę sam z tym poradzić. Z góry dziękuję za pomoc. Pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie
- darth_sidious   Problem z tworzeniem i (chyba) auto_increment   6.01.2007, 23:47:00
- - nospor   no chyba wyraźnie ci napisalo: CytatIncorrect tabl...   7.01.2007, 11:19:19
- - darth_sidious   Tzn, ze jesli ktores pole jest auto_increment to m...   7.01.2007, 11:46:57
- - nospor   tak. wkoncu autoincrement jednoznacznie definiuje ...   7.01.2007, 11:48:27
- - darth_sidious   No mam dylemat... Jak juz pisalem zmieniam orygina...   7.01.2007, 11:51:24
- - wipo   Ale już Ci to napisał nospar że nie można w obrębi...   7.01.2007, 11:56:01
- - nospor   wydaje mi sie troche dziwne robic klucz glowny z p...   7.01.2007, 11:57:26
- - darth_sidious   Skrypt powinien dzialac na php 4.0 lub nowszym i b...   7.01.2007, 12:13:20
- - nospor   Cytatna php 4.0 lub nowszym i bazie MySql mi wlas...   7.01.2007, 12:17:01
- - darth_sidious   No wlasnie o wersji bazy nie ma mowy....   7.01.2007, 12:23:20
- - wipo   Nie jesteś pewnien jaka baza czy która wersja?   7.01.2007, 12:30:01
- - darth_sidious   Bazy jestem pewien - mysql... nie mam pewnosci co ...   7.01.2007, 12:31:34
- - nospor   moze ty tworzysz tabele typu innoDB? bo znalazlem ...   7.01.2007, 12:41:34
- - darth_sidious   OK... przyjrze sie temu blizej... postaram sie cos...   7.01.2007, 12:51:47
- - nospor   ale co tu kombinowac? musisz dopisac na koniec sql...   7.01.2007, 12:53:04
- - darth_sidious   Wielkie dzieki Po dodaniu [PHP] pobierz, plain...   7.01.2007, 15:15:06
- - jarek26   Witam. Mógłby mi ktokolwiek pomóc gdyż mam podobny...   2.10.2010, 08:44:10
- - nospor   Przeciez masz wyraźnie napisane: Moze byc tylko je...   4.10.2010, 06:05:56


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.12.2025 - 14:17