Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Php i mysql, problem z dodaniem danych do tabel
saperek25
post 9.11.2010, 18:50:04
Post #1





Grupa: Zarejestrowani
Postów: 52
Pomógł: 0
Dołączył: 1.11.2009
Skąd: Bytom

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


  1. <?php
  2. //połączenie z serwerem MySQL
  3. $connect = mysql_connect("localhost", "root", "tatiana13")
  4. or die ("Sprawdź połączenie z serwerem.");
  5.  
  6. //uaktywnij odpowiednią bazę
  7. mysql_select_db("moviesite");
  8.  
  9. //wstaw dane do tabeli "movie"
  10. $insert = "INSERT INTO movie (movie_id, movie_name, movie_type, " ,
  11. "movie_year, movie_leadactor, movie_director) " ,
  12. "VALUES (1, 'Bruce Wszechmogący', 5, 2003, 1, 2), " ,
  13. "(2, 'Życie biurowe', 5. 1999, 5, 6), " ,
  14. "(3, 'Wielki Kanion', 2, 1991, 4, 3)";
  15. $result = mysql_query($insert)
  16.  
  17. //wstaw dane do tabeli "movietype"
  18. $type = "INSERT INTO movietype (movietype_id, movietype_label) ",
  19. "VALUES (1, 'Sciene-fiction'). " ,
  20. "(2, 'Dramat'), " ,
  21. "(3, 'Przygoda'), " ,
  22. "(4, 'Wojenny') , " ,
  23. "(5, 'Komedia') ," ,
  24. "(6, 'Horror') , " ,
  25. "(7, 'Akcja'), " ,
  26. "(8, 'Dla dzieci')";
  27. $result = mysql_query($type)
  28.  
  29. //wstaw dane do tabeli "people"
  30. $people = "INSERT INTO people (people_id, people_fullname, " ,
  31. "people_isactor, people_isdirector) ",
  32. "VALUES (1, 'Jim Carey', 1, 0), ",
  33. "(2, 'Tom Shadyac', 0, 1), " ,
  34. "(3, 'Lawrence Kasdan', 0, 1), ",
  35. "(4, Kevin Kline', 1, 0), " ,
  36. "(5, 'Ron ivingston', 1, 0), " ,
  37. "(6, 'Mike Judge', 0, 1)";
  38. $result = mysql_query($people)
  39.  
  40. echo "Dane zostały dodane poprawnie!";


wywala błąd 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 '), (2, 'Dramat') , (3, 'Przygoda') , (4, 'Wojenny') , (5, 'Komedia') ,(6, 'Horro' at line 1
nigdzie nie widzę literówki

Ten post edytował Ociu 9.11.2010, 19:31:06
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 03:49