Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z utworzeniem bazy
dejmen
post
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 9.04.2011

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


Otóż chcę utworzyć bazę z poziomu php oto skrypt

  1. <?php
  2. $connect = mysql_connect("localhost", "root", "mysql");
  3.  
  4.  
  5. $create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite")
  6.  
  7. mysql_select_db("moviesite");
  8.  
  9. $movie = "CREATE TABLE movie (
  10. movie_id int(11) NOT NULL auto_increment,
  11. movie_name varchar(255) NOTNULL,
  12. movie_type tinyint(2) NOT NULL default 0,
  13. movie_year int(4) NOT NULL default 0,
  14. movie_leadactor int(11) NOT NULL default 0,
  15. movie_director int(11) NOT NULL default 0,
  16. PRIMARY KEY (movie_id),
  17. KEY movie_type (movie_type,movie_year)
  18. )";
  19.  
  20. $results = mysql_query($movie)
  21.  
  22. $movietype = "CREATE TABLE movietype (
  23. movietype_id int(11) NOT NUL auto_increment,
  24. movietype_label varchar(100) NOT NULL,
  25. PRIMARY KEY (movietype_id)
  26. )";
  27.  
  28. $results = mysql_query($movietype)
  29.  
  30. $people = "CREATE TABLE people (
  31. people_id int(11) NOT NULL auto_increment,
  32. people_fullname varchar (255) NOT NULL,
  33. people_isactor tinyint(1) NOT NULL default 0,
  34. people_isdirector tinyint(1) NOT NULL default 0,
  35. PRIMARY KEY (people_id)
  36. )";
  37.  
  38. $results = mysql_query($people)
  39.  
  40. echo "Poprawnie utworzono baze filmów";
  41. ?>


gdy próbuje otworzyć plik wyskakuj taki 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 'NOTNULL, movie_type tinyint(2) NOT NULL default 0, movie_year int(4) NOT NULL ' at line 3"
nie umiem znaleść źródła błędu bardzo proszę o pomoc
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 Aktualny czas: 21.08.2025 - 07:30