Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 December 5th, 2007, 12:29 PM
Registered User
 
Join Date: Dec 2007
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old December 5th, 2007, 12:34 PM
Registered User
 
Join Date: Dec 2007
Location: , , .
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...

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



All times are GMT -4. The time now is 01:38 PM.


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