Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z zapytaniem
regua
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.04.2006
Skąd: Kraków

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


Napisałem coś w rodzaju prostego CMSa, no i chcę zrobić skrypt instalacyjny, bo to jakoś głupio jak user musi sam wykonywać polecenia SQL, tworzyć pliki.... (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) No i wszystko jest gut, gdyby nie to, że przy wykonywaniu
  1. $sql = "CREATE TABLE `posts` (
  2. `id` smallint(6) NOT NULL auto_increment,
  3. `data` varchar(16) NOT NULL default '',
  4. `tresc` text NOT NULL,
  5. `autor` smallint(6) NOT NULL default '',
  6. `temat` smallint(6) NOT NULL default '',
  7. PRIMARY KEY (`id`)
  8. ) TYPE=MyISAM;
  9. CREATE TABLE `topics` (
  10. `id` smallint(6) NOT NULL auto_increment,
  11. `temat` varchar (64) NOT NULL default '',
  12. PRIMARY KEY (`id`)
  13. ) TYPE=MyISAM;
  14. CREATE TABLE `users` (
  15. `userid` smallint(6) NOT NULL auto_increment,
  16. `posts` smallint (6) NOT NULL default '',
  17. `name` varchar (64) NOT NULL default '',
  18. `mail` varchar (64) NOT NULL default '',
  19. `www` varchar (64) default '',
  20. `opis` text default '',
  21. `pass` varchar (64) NOT NULL default '',
  22. PRIMARY KEY (`userid`)
  23. ) TYPE=MyISAM;
  24. CREATE TABLE `news` (
  25. `id` smwszystkieint(6) NOT NULL auto_increment,
  26. `data` varchar(16) NOT NULL default '',
  27. `tresc` text NOT NULL,
  28. `temat` varchar(64) NOT NULL default '',
  29. PRIMARY KEY (`id`)
  30. ) TYPE=MyISAM;
  31. CREATE TABLE `komentarze` (
  32. `id` smwallint(6) NOT NULL auto_increment,
  33. `newsid` smallint(6) NOT NULL auto_increment,
  34. `tresc` text NOT NULL,
  35. `autor` smallint(6) NOT NULL default '',
  36. PRIMARY KEY (`id`)
  37. ) TYPE=MyISAM;
  38. CREATE TABLE `config` (
  39. `name` varchar(64) NOT NULL default '',
  40. `value` varchar(64) NOT NULL default '',
  41. PRIMARY KEY (`name`)
  42. ) TYPE=MyISAM;
  43. CREATE TABLE `chat` (
  44. `id` smallint(6) NOT NULL auto_increment,
  45. `autor` smallint(6) NOT NULL default '',
  46. `tresc` text NOT NULL,
  47. PRIMARY KEY (`id`)
  48. ) TYPE=MyISAM; ";

wywala
  1. You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MySQL server version FOR the RIGHT syntax TO USE near '; CREATE TABLE `topics` ( `id` smallint(6) NOT NULL auto_increment, `temat` v' at line 8 )

a przy
  1. $sql = "INSERT
  2. INTO `users`
  3. VALUES ('', '0', '".$_POST['user']."', '".$_POST['mail']."', '".$_POST['domain'].$_POST['path']."', 'Administrator', '".md5($_POST['pass'])."');
  4. INSERT
  5. INTO `topics`
  6. VALUES ('', 'Testowy temat');
  7. INSERT
  8. INTO `posts`
  9. VALUES ('', '".date(d.'.'.m.'.'.y.', '.H.':'.i)."', 'Tresc testowego posta', '1', '1');
  10. INSERT
  11. INTO `news`
  12. VALUES ('', '".date(d.'.'.m.'.'.y.', '.H.':'.i)."', 'Tresc testowego newsa', 'Testowy news');
  13. INSERT
  14. INTO `config`
  15. VALUES ('domain', '".$_POST['domain']."');
  16. INSERT
  17. INTO `config`
  18. VALUES ('path', '".$_POST['path']."');
  19. INSERT
  20. INTO `config`
  21. VALUES ('npp', '10');";

wywala
  1. You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MySQL server version FOR the RIGHT syntax TO USE near '; INSERT
  2. INTO `topics`
  3. VALUES ('', 'Testowy temat'); INSERT
  4. INTO `posts`
  5. VALUES ' at line 1 )

Łączność z bazą danych następuje prawidłowo (skrypt wyświetla poprawność wykonania poszczególnych etapów), tylko problemy z tym SQLem... gdy wykonuję te zapytania przez phpMyAdmina, to.... wszystko idzie dobrze (IMG:http://forum.php.pl/style_emoticons/default/blink.gif) Czego to może być wina?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




mozna wykonac naraz tylko jedno zapytanie. A ty wrzucasz tych zapytan na raz x (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Musisz kazdego create wrzucic do odzielnej zmiennej i kazdego pokolei wykonywac
Podobnie z insert
Go to the top of the page
+Quote Post
regua
post
Post #3





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.04.2006
Skąd: Kraków

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


(IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif)
Nie wiedziałem tego... phpMyAdmin sobie radzi...
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




do PMA zapodajesz zapytania i on zapewne je sobie rozbija.
Jak tak barddzo ci zalezy, to se napisz klase co tez bedzie rozbijac (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

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: 20.12.2025 - 15:42