Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | 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 November 4th, 2008, 01:00 AM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3 page 95

the book is excellent. I was doin great, so I thought. I'm having a problem. The moviedata database was created. However, the only error I get is this one: "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 '), (3, 'Grand Canyon', 2, 1991, 4, 3)' at line 1"

The test environment that I'm using is PHP5 and Mysql 5. I realized that the one on the book is an older version (Mysql 4). Can anyone tell me what syntax to use, so it would work? Thanks!

this is the code:
<?php
//connect to mysql
$connect = mysql_connect('localhost', 'root')
or die ("Check your server connection and try again");

//make sure we are using the right database

mysql_select_db("moviesite");

    $insert = "INSERT INTO movie (movie_id, movie_name, movie_type, " .
    "movie_year, movie_leadactor, movie_director) " .
    "VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), " .
    "(2, 'Office Space', 5, 1999, 5, 6,), " .
    "(3, 'Grand Canyon', 2, 1991, 4, 3)";
$results = mysql_query($insert)
 or die(mysql_error());

//insert data into moviesite 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());

//insert data into "people" table

$people = "INSERT INTO people (people_id, people_fullname, " .
    "people_isactor, people_isdirector) " .
    "VALUE (1, 'Jim Carrey', 1, 0), " .
    "(2, 'Tom Shaday', 0, 1), " .
    "(3, 'Lawrence Kasdan', 0, 1), " .
    "(4, 'Kevin Kline', 0, 1), " .
    "(5, 'Ron macray', 0, 1), " .
    "(6, 'Mike Shaday', 0, 1)";
$results = musql_query($people)
 or die(mysql_error());

echo "Data inserted successfullly!";
?>

Reply With Quote
  #2 (permalink)  
Old November 4th, 2008, 07:38 AM
Registered User
 
Join Date: Oct 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First, please understand I am very new to this as well. I had the exact same problem when I was there, If I remember correctly I fixed it by replacing the movie_id numbers with NULL. In the create movie.php file we have movie_id int(11) NOT NULL auto_increment. If this is auto incremented AND we assign a value to the ID it will cause an error. So, we need to assign a NULL value to it and let php assign the values.

I hope this helps you.

Reply With Quote
  #3 (permalink)  
Old March 26th, 2009, 09:28 AM
Registered User
 
Join Date: Jul 2008
Location: Melbourne, Victoria, Australia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you haven't copied to code correctly. The first mistake is highlighted by your mysql error message.

you wrote :
"(2, 'Office Space', 5, 1999, 5, 6,), "

you needed to write :
"(2, 'Office Space', 5, 1999, 5, 6), "

only 1 little comma (,) after the 6. MySQL is probably showing you have not entered anything after the 6 and in effect added another data set to your list.
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
Pass 1z0-042 With 95% ucham VBScript 1 July 25th, 2013 08:45 AM
Chapter 3 Page 95 jumpot89 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 6 April 22nd, 2009 03:11 AM
Chapter 3 pg 95 al2000 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 August 4th, 2008 09:18 PM
Chapter 3, page 95 Swerve1000 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 May 29th, 2007 04:45 PM
It wont Connect toMySQLChapter 3,Page 95-98, Alej PHP Databases 3 August 29th, 2006 11:37 PM



All times are GMT -4. The time now is 04:23 AM.


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