Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 January 13th, 2007, 03:59 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
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!

Reply With Quote
  #2 (permalink)  
Old January 14th, 2007, 10:06 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
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.

Reply With Quote
  #3 (permalink)  
Old January 15th, 2007, 06:19 PM
Authorized User
 
Join Date: Jul 2006
Location: Happaugh, NY, .
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.

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



All times are GMT -4. The time now is 11:34 PM.


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