 |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
 | This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 30th, 2011, 12:12 PM
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Chapter 3 p.87-89 MySql Table 'movie' already exists message and syntax error
I'm having a problem viewing my database named db_ch03-1.php after following the example in the book. The message says Table 'movie' already exists but I don't know why or if this is what it should say?
In the corresponding script for db_ch03_2.php the browser shows the error message:
Duplicate entry '1' for key 'PRIMARY'
Can't see the error after checking over and over and the script is below:
Code:
<?php
//connect to MySQL
$db = mysql_connect ('localhost', 'root', '') or
die('Unable to connect. Check your connection parameters.');
//make sure our recently created datbase is the active one
mysql_select_db('moviesite', $db) or die(mysql_error($db));
//insert data into the movie table
$query = '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)';
mysql_query($query, $db) or die (mysql_error($db));
//insert data into movietype table
$query = 'INSERT INTO movietype
(movietype_id, movietype_label)
VALUES
(1, "SCI FI"),
(2, "Drama"),
(3, "Adventure"),
(4, "War"),
(5, "Comedy"),
(6, "Horror"),
(7, "Action"),
(8, "Kids"")';
mysql_query($query, $db) or die (mysql_error($db));
//insert data into people table
$query = 'INSERT INTO people
(people_id, people_fullname, people_isactor, people_isdirector)
VALUES
(1, "Jim Carey", 1, 0),
(2, "Tom Shadyac", 0, 1),
(3, "Lawrence Kasdan", 0, 1),
(4, "Kevin Kline", 1, 0),
(5, "Ron Livingston", 1, 0),
(6, "Mike Judge", 0, 1)';
mysql_query($query, $db) or die (mysql_error($db));
echo 'Data inserted succcessfully!';
?>
If anyone out there can help I would really appreciate it as I want to see some results and grow my database 
Last edited by hunt4it; May 30th, 2011 at 04:14 PM..
|
|

June 1st, 2011, 07:43 PM
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
I know that this may be because I have tested the database a number of times so am going to delete tables and start again to see if this works. Could not find an option to delete this post, sorry all. 
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| chapter 3 page 89: HTTP 500 internal server error |
igtoroy |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 |
7 |
February 23rd, 2010 11:08 AM |
| mysql syntax error - Chapter 3th |
[email protected] |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 |
2 |
January 12th, 2010 08:56 AM |
| Ch3 Appendix MySQL Syntax Error |
amin7b5 |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
0 |
April 16th, 2008 01:49 PM |
| syntax error message |
luctondo |
Beginning PHP |
1 |
May 20th, 2006 10:40 AM |
|
 |