Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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 December 5th, 2007, 12:29 PM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default You have an error in your SQL syntax; check the ma

Hi

Can anyone help me sort out this error message... i'm a complete newbie to php... and after studying this forum have found some typos are in the books... so i don't know if its me causing the error, or its because of a typo...

I have tried all sorts of stuff, and it hasn't gone...

The error message is:


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 ' PRIMARY (movie_id), KEY movie_type (movie_type,movie_year) )' at line 7


I'm only on the real basic stuff

Book: Begining PHP5, Apache, MySQL, Web Development
Page: 94

note i blanked out some of the lower code to try and home-in on the error

Will my server settings have anything to do with it? I'm allready running some other PHP and database code on them from a template... and now i'm trying to learn it myself... anyways...

The Code IS:

<?PHP
//connect to MySQL
$connect = mysql_connect("localhost", "myusername_bp5am", "bp5ampass") or die ("check your server connection parameters.");


//create the main database if it does not allready exist
$create = mysql_query("CREATE DATABASE myusername_moviesite") or die (mysql_error());

//make sure our recently created database is the active one
mysql_select_db("myusername_moviesite");




///////////////////////////////////////////////////////////////////
// CREATE TABLES BELOW
///////////////////////////////////////////////////////////////////

//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,
    PRIMARY (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
//$movietype = "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 Successfully Created!";
?>



Many Thanks

 
Old December 5th, 2007, 12:34 PM
Registered User
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please ignore the fact that "KEY" is missing from "PRIMARY KEY". On my last attempt at sorting this error before my post i removed it to test, and i still got the error... forgot to put it back in for the post...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in SQL syntax phantom3008 ASP.NET 1.0 and 1.1 Basics 1 April 26th, 2007 07:00 AM
Example SQL causes syntax error Tom Rigby BOOK: Beginning SQL 1 April 18th, 2007 09:32 AM
SQL syntax error - Chapter 3 cutthroatchemist BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 January 15th, 2007 06:19 PM
SQL Syntax Error I can't figure out Syster Tara Classic ASP Basics 24 December 2nd, 2006 05:09 PM
Syntax error on SQL statement Chris1 Access VBA 1 September 7th, 2004 07:47 AM





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