 |
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
|
|
|
|

January 5th, 2011, 04:41 PM
|
|
Registered User
|
|
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Question about Error in Chapter 3.
I was doing the first example for creating a database for file db_ch03-1.php, but I ran into problems when execution my code.
The code that I have is:
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 dosen't already exist.
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query, $db) or die(mysql_error($db));
//make sure our recently created database 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 DEAFULT 0,
movie_director INTEGER UNSINGED NOT NULL DEFAULT 0,
PRIMARY KEY(movie_id),
KEY movie_type (movie_type, movie_year)
)
ENGINE=MyISAM';
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=MyISAM';
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(255) NOT NULL,
people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
people_isdirector TYNYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (people_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
echo 'Movie database successfully created!';
The problem is that when I run this as http://localhost/db-ch03.php in firefox I receive this error:
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 'DEAFULT 0, movie_director INTEGER UNSINGED NOT NULL DEFAULT 0, PR' at line 6
I am not sure why but I checked the code several times and I am not sure where I am having this syntax error.
Could it be because I did not use the username and the password that is used in the book?
Thank you for your help.
|
|

February 19th, 2011, 01:49 PM
|
|
Registered User
|
|
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hehe i am on chapter 4 so I can help you :). Line 6 on mysql Select so change unsinged to unsigned
movie_director INTEGER UNSINGED NOT NULL DEFAULT 0,
Quote:
Originally Posted by Vladius101
I was doing the first example for creating a database for file db_ch03-1.php, but I ran into problems when execution my code.
The code that I have is:
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 dosen't already exist.
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query, $db) or die(mysql_error($db));
//make sure our recently created database 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 DEAFULT 0,
movie_director INTEGER UNSINGED NOT NULL DEFAULT 0,
PRIMARY KEY(movie_id),
KEY movie_type (movie_type, movie_year)
)
ENGINE=MyISAM';
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=MyISAM';
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(255) NOT NULL,
people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
people_isdirector TYNYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (people_id)
)
ENGINE=MyISAM';
mysql_query($query, $db) or die(mysql_error($db));
echo 'Movie database successfully created!';
The problem is that when I run this as http://localhost/db-ch03.php in firefox I receive this error:
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 'DEAFULT 0, movie_director INTEGER UNSINGED NOT NULL DEFAULT 0, PR' at line 6
I am not sure why but I checked the code several times and I am not sure where I am having this syntax error.
Could it be because I did not use the username and the password that is used in the book?
Thank you for your help.
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| chapter 3 question |
adamshire |
BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 |
1 |
July 29th, 2010 06:09 PM |
| Chapter 5 Question |
jltscaa |
BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 |
6 |
May 18th, 2010 08:39 PM |
| A better example of Chapter 5 Question 6 |
dspearing |
BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 |
1 |
April 6th, 2010 08:16 PM |
| Chapter 5 Question 5 |
Will |
BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 |
1 |
October 24th, 2009 09:18 AM |
|
 |