Wrox Programmer Forums
|
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
 
Old June 1st, 2011, 07:36 PM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default Table people doesn't exist CH3 p.87-89

Hiya

I have created all of my tables as per the book but when I run the scripts I get the message that the table people doesn't exist although I'm sure it has been created with the associating script inserting data. The script used is below:

Code:
<?php
//connect to MySQL



$db = mysql_connect ('localhost', 'root', '') or
	die ('Unable to connect. Check your connection parameters.');

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

//make sure our recently created datbase is the active one 
mysql_select_db('moviesite', $db) or die(mysql_error($db));

//create the movie table
$query = 'CREATE TABLE movie (

	movie_id	INTEGER UNSIGNED   NOT NULL AUTO_INCREMENT,
	movie_name	VARCHAR (255)	   NOT NULL,
	movie_type	TINYINT		   NOT NULL DEFAULT 0,
	movie_year	SMALLINT UNSIGNED  NOT NULL DEFAULT 0,
	movie_leadactor INTEGER UNSIGNED   NOT NULL DEFAULT 0,
	movie_director  INTEGER UNSIGNED   NOT NULL DEFAULT 0,

	PRIMARY KEY (movie_id),
	KEY movie_type (movie_type, movie_year)

	)
	
	ENGINE=MySAM';
mysql_query($query, $db) or die (mysql_error($db));

//create the movietype table
$query = 'CREATE TABLE movietype (
	movietype_id	TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
	movietype_label VARCHAR(100)     NOT NULL,
	PRIMARY KEY (movietype_id)
	)
	ENGINE=MySAM';
mysql_query($query, $db) or die (mysql_error($db));

//create the people table
$query = 'CREATE TABLE people (
	people_id	  INTEGER UNSIGNED	NOT NULL AUTO_INCREMENT,
	people_fullname   VARCHAR (225)		NOT NULL,
	people_isactor    TINYINT (1) UNSIGNED	NOT NULL DEFAULT 0,
	people_isdirector TINYINT (1) UNSIGNED  NOT NULL DEAFULT 0,

	PRIMARY KEY (people_id)

	)
	ENGINE=MySAM';
mysql_query($query, $db) or die (mysql_error($db));

echo 'Movie database successfully created!';

?>
After using MySql console to check this using SHOW TABLES it only shows the tables for movie and movie_type. I have deleted all tables and then re-started Wamp Server to run again but still no joy.

Can anyone explaim why this is happeining as I don't think it's a syntax error?
 
Old June 5th, 2011, 03:26 AM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default People tables does not exists!

Table people does not exists because of an extra space in table's definitions for people_fullname, people_isactor and people_isdirector variables.

Your code is as following:-
Code:
//create the people table
$query = 'CREATE TABLE people (
	people_id	      INTEGER UNSIGNED	NOT NULL AUTO_INCREMENT,
	people_fullname   VARCHAR (225)		NOT NULL,
	people_isactor    TINYINT (1) UNSIGNED	NOT NULL DEFAULT 0,
	people_isdirector TINYINT (1) UNSIGNED  NOT NULL DEAFULT 0,

	PRIMARY KEY (people_id)

	)
	ENGINE=MySAM';
mysql_query($query, $db) or die (mysql_error($db));
The correct code should be as following:-

Code:
//create the people table
$query = 'CREATE TABLE people (
	people_id	      INTEGER UNSIGNED	NOT NULL AUTO_INCREMENT,
	people_fullname   VARCHAR(225)		NOT NULL,
	people_isactor    TINYINT(1) UNSIGNED	NOT NULL DEFAULT 0,
	people_isdirector TINYINT(1) UNSIGNED   NOT NULL DEAFULT 0,

	PRIMARY KEY (people_id)

	)
	ENGINE=MySAM';
mysql_query($query, $db) or die (mysql_error($db));

Last edited by atv41; June 5th, 2011 at 03:30 AM..
The Following User Says Thank You to atv41 For This Useful Post:
hunt4it (June 5th, 2011)
 
Old June 5th, 2011, 07:32 PM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ahhh, hadn't noticed this small thing so will check closely for this in the future. Thanks for that I can crack on now (though sure I will have other challenges along the way.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3 p.87-89 MySql Table 'movie' already exists message and syntax error hunt4it BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 1 June 1st, 2011 07:43 PM
Ch3 Moviesite table already exists? aiche_ag BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 August 7th, 2007 01:29 PM
Table Exist? elansolutionsltd Access VBA 5 January 23rd, 2006 03:43 AM
No Code for 'People Table' in Chapt 17 peterstandard BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 January 1st, 2005 01:07 AM
pg190 edit/delete code for 'people' table ?? jeronimo BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 June 28th, 2004 01:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.