Wrox Programmer Forums
|
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
 
Old December 7th, 2009, 09:46 AM
Authorized User
 
Join Date: Dec 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default mysql syntax error - Chapter 3th

Hello all, i bought your book "PHP6, Apache, MySQL Web development, but i just have some problem with my first mysql code in php...
Sorry, but I am new in this forum, can i have some help ?
My php code is the next:
Code:
<?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
 
Old January 2nd, 2010, 06:23 PM
Authorized User
 
Join Date: Jan 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Refer to pg 87 and try removing the "," from this line:

PRIMARY KEY (movietype_id),


FROM:

PRIMARY KEY (movietype_id),

TO:

PRIMARY KEY (movietype_id)

Hope it helps.

Last edited by s.c.; January 4th, 2010 at 12:03 AM..
The Following User Says Thank You to s.c. For This Useful Post:
[email protected] (January 12th, 2010)
 
Old January 12th, 2010, 08:56 AM
Authorized User
 
Join Date: Dec 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by s.c. View Post
Refer to pg 87 and try removing the "," from this line:

PRIMARY KEY (movietype_id),


FROM:

PRIMARY KEY (movietype_id),

TO:

PRIMARY KEY (movietype_id)

Hope it helps.

Thank You for your availability!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch3 Appendix MySQL Syntax Error amin7b5 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 April 16th, 2008 01:49 PM
chapter 6: scaffold syntax error cwhite124 BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:20 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
chapter 6, page 173-175, error in sql syntax vkranendonk BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 May 26th, 2004 12:30 PM
Syntax error for chapter 15 AddUser.asp gymmic Classic ASP Databases 7 April 20th, 2004 02:00 AM





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