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

November 4th, 2008, 01:00 AM
|
|
Registered User
|
|
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!";
?>
|
|

November 4th, 2008, 07:38 AM
|
|
Registered User
|
|
Join Date: Oct 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

March 26th, 2009, 09:28 AM
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
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 |
|
 |