Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z utworzeniem bazy
Forum PHP.pl > Forum > Bazy danych
dejmen
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
blooregard
Cytat
movie_name varchar(255) NOTNULL,


NOT NULL

dejmen
Wielkie dzieki, tylko że po zmianie wyskakuje kolejny o 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 'NUL auto_increment, movietype_label varchar(100) NOT NULL, PRIMARY KEY (moviet' at line 2
(prosze o zrozumienie jestem początkujący)
mat-bi
  1. NOT NUL


zmień na

  1. NOT NULL


przez dwa l
blooregard
Cytat
to use near 'NUL auto_increment, movietype_label


NULL

Dwa 'L' na końcu.
dejmen
Wielkie dzięki ;D
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.