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

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: 23.12.2025 - 13:48