Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 9th, 2009, 06:38 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Duplicate entry '1' for key 1

Anybody got this one before?
Duplicate entry '1' for key 1


based on the code from the book p 94-96 I have created the tables:
movie
movietype

it seems I can't create the people table neither to populate the movietype.

Any help?

createmovie.php:

<?
// connect to MySQL
$connect = mysql_connect("localhost", "xxx", "xxx") or
die ("Check your server connection. Sorry");

// create the main database if it doesn't yet exist
$create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite")
or die(mysql_error());

//make sure your 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 "movietype" table
$movietype = "CREATE TABLE movietype (
movietype_id int(11) NOT NULL auto_increment,
movietype_label varchar(100) NOT NULL,
PRIMARY KEY (movietype_id)
)";

$results = mysql_query($movietype)
or die(mysql_error());

// create "people" table
$people = "CREATE TABLE people (
people_id int(11) NOT NULL auto_increment,
people_fullname varchar(255) NOT NULL,
people_isactor tinyint(1) NOT NULL default 0,
people_isdirector tinyint(1) NOT NULL default 0,
PRIMARY KEY (people_id)
)";

$results = mysql_query($people)
or die(mysql_error());

echo "Movie database succesfully created!";
?>
Reply With Quote
  #2 (permalink)  
Old February 9th, 2009, 06:56 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution

Just cleared the old tables and submitted the createmovie.php using the code from the book. Probably stupid spelling error but it run ok this time.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for duplicate entry in Database sharon5469 ASP.NET 1.0 and 1.1 Basics 1 November 18th, 2007 06:08 PM
Duplicate database entry redirection error page EmWebs Dreamweaver (all versions) 3 December 29th, 2006 10:17 AM
Duplicate database entry redirection error page EmWebs Access ASP 0 December 27th, 2006 12:54 PM
avoid duplicate entry of records mikersantiago Classic ASP Basics 4 February 10th, 2005 09:14 PM
deleting only 1 duplicate entry qwjunk Classic ASP Databases 3 February 2nd, 2004 11:45 AM



All times are GMT -4. The time now is 08:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.