MySQL Forums
Forum List  »  MySQL Administrator

SQL syntax error
Posted by: Riccardo DE GIOVANNI
Date: December 06, 2009 09:03AM

Hello all, i am new in this forum, but i have some problem about my first mysql code in php...
My php code is the next:
________________________________________
<?php
// collegamento a MySQL
$db=mysql_connect('localhost','bp6am','bp6ampass') or
die ('Unable to connect. Check your connection parameters.');

// crea il database principale se non esiste
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query, $db) or die(mysql_error($db));

// per sicurezza seleziona come attivo il database appena creato
mysql_select_db('moviesite', $db) or die(mysql_error($db));

// crea la tabella movie
$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=MyISAM';
mysql_query($query, $db) or die (mysql_error($db));

// crea la tabella movietype
$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));

// crea la tabella people
$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 TINYINT (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!';
?>

______________________________________________

When i submit this code on apache server (localhost on my computer), went out next 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 ') ENGINE=MyISAM' at line 5

My mysql installed on my computer is 5.1.40 version, my apache server installed is 2.2.14 version and the php installed is 5.2.11 version!

I'm sorry for my English, but i need a fast solution...
Thank All for all in advance!
Ricky

Options: ReplyQuote


Subject
Written By
Posted
SQL syntax error
December 06, 2009 09:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.