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
|