Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 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 January 13th, 2007, 03:59 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL syntax error - Chapter 3

Hi,

I received the following message in creating the moviedata file:

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 '. (6, 'Horror'), (7, 'Action'), (8, 'Kids')' at line 1

Here is the excerpted code:

//insert data into "movietype" table
$type = "INSERT INTO movietype (movietype_id, movietype_label) " .
    "VALUES (1, 'Sci Fi'), " .
    "(2, 'Drama'), " .
    "(3, 'Adventure'), " .
    "(4, 'War'), " .
    "(5, 'Comedy'), " .
    "(6, 'Horror'), " .
    "(7, 'Action'), " .
    "(8, 'Kids')";
$results = mysql_query($type)
    or die(mysql_error());

I had mistakenly put in a period instead of a comma after War and had the error initially. I went back and changed to a comma and still get an error. Where is the error???

Thanks!

 
Old January 14th, 2007, 10:06 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, I went back and retyped in a part (the same thing again) and reran the script. This time I received the message that the table is already created error. So I dropped the database altogether and reran both scripts and am fine for now.

 
Old January 15th, 2007, 06:19 PM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the future you can do this:

b]$clearsql = "TRUNCATE TABLE "tablename"";
$results = mysql_query($clearsql)
or die(mysql_error());[/b]

then run the sql statement - this will clear the table before the right to it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 6: scaffold syntax error cwhite124 BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:20 AM
Chapter 1: SQL script syntax Elphick BOOK: Beginning VB.NET Databases 5 June 30th, 2007 06:31 AM
Example SQL causes syntax error Tom Rigby BOOK: Beginning SQL 1 April 18th, 2007 09:32 AM
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.