Jump to content

Birdzview

Members
  • Posts

    3
  • Joined

  • Last visited

Birdzview's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Mikosiko, Thank you ! I removed the PRIMARY reference in the INSERT and also the digits in VALUES and it worked Appreciated
  2. Yes, that's exactly the problem - but how shall I fix it ? Please look at the code of CREATEMOVIE.PHP that generated the table - does the problem lie here ? Or does the problem lie with the data itself that I want to upload from MOVIEDATA.PHP ? Where do I find the table that was generated to see the data in it ?
  3. Please help, anybody Duplicate entry '1' for key 'PRIMARY' - The message I get when running my moviedata.php See also moviecreate.php that creates the database Here are the parts involved : A) MOVIEDATA.PHP (THE PROBLEM ONE) <?php //insert data into "movie" table $insert = "INSERT INTO movie(movie_id, movie_name, movie_type, " . "movie_year, movie_leadactor, movie_director) " . "VALUES(1, 'Bruce Almighty', 5, 2003, 1, 2), " . "(2, 'Office Space', 5, 1999, 5, 6), " . "(3, 'Grand Canyon', 2, 1991, 4, 3)"; $results = mysql_query($insert) or die(mysql_error()); ?> B) CREATEMOVIE.PHP (WORKS JUST FINE) <?php //connect to MySQL $connect = mysql_connect("localhost", "root", "") or die ("Hey boy, check your server connection."); //create the main database if it doesn't already exist $create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite") or die(mysql_error()); //make sure our recently created database is the active one mysql_select_db("moviesite"); //create "movie" table $movie = "CREATE TABLE movie ( movie_id int(11) NOT NULL auto_increment, movie_name varchar(255) NOT NULL, movie_type tinyint(2) NOT NULL default 0, movie_year int(4) NOT NULL default 0, movie_leadactor int(11) NOT NULL default 0, movie_director int(11) NOT NULL default 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) )"; $results = mysql_query($movie) or die (mysql_error()); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.