Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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 May 23rd, 2004, 05:52 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 6, page 173-175, error in sql syntax

Hello,

On chapter 6, page 173-175 I get an error in my mysql syntax. I don't know whats wrong with it I have tried several things.

I hope somebody can help me.

This is the error that is displayed.

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 ') VALUES ( 'Vincent,' , '2002' , '3' , '3' ,

This is the text file:

<?php
//************************************************** ************************************************** ********
//commit add
//************************************************** ************************************************** ********
  $link = mysql_connect("localhost", "root", "kranendonk") or die(mysql_error());
  $select = mysql_select_db("wiley", $link) or die(mysql_error());
  switch( $_GET['action'] ){
    case "add":
  switch( $_GET['type'] ){
    case "movie":
  $sql = "INSERT INTO
      `movie`
    ( `movie_name`,
      `movie_year`,
      `movie_type`,
        `movie_leadactor`,
      `movie_director`,)
      VALUES
    ( '".$_POST['movie_name'].",' ,
      '".$_POST['movie_year']."' ,
      '".$_POST['movie_type']."' ,
      '".$_POST['movie_leadactor']."' ,
      '".$_POST['movie_director']."' )
      ";
    break;
  }
    break;
}
if ( isset( $sql ) && !empty( $sql )){
  echo "<!-".$sql."->";
  $result = mysql_query( $sql ) or die(mysql_error());
?>
  <p align="center" style="color:#FF0000">
    Done. <a href="index.php">Index</a>
  </p>
<?php
  }
?>

If somebody could help me i will be verry happy.

 
Old May 24th, 2004, 06:08 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

The error is here

 ( 'Vincent,' , '2002' , '3' , '3' ,

You are missing two single quotes.

So it needs to be

 ( 'Vincent', '', '2002' , '3' , '3' ,

since your VALUES have to match the number of columns you specify.

HTH!




Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old May 24th, 2004, 06:10 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Oops I misread your code, actually you have one too many commas.. so it needs to be:

 ( 'Vincent', '2002' , '3' , '3' ,

Or in the context of your code:

Code:
      '".$_POST['movie_name']."',
      '".$_POST['movie_year']."',
      '".$_POST['movie_type']."',
      '".$_POST['movie_leadactor']."',
      '".$_POST['movie_director']."' )
HTH!

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old May 26th, 2004, 12:30 PM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Heej, thanks for answering on my problem. But that wasn't the problem.

I had a "," to much in my mysql syntax.

      `movie`
    ( `movie_name` ,
      `movie_year` ,
      `movie_type` ,
        `movie_leadactor` ,
      `movie_director`, )

greetings, vincent kranendonk






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 example (p. 173) Tim BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 3 August 3rd, 2008 09:04 PM
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
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
ASP Error Message 173 renisar Classic ASP Databases 9 December 19th, 2003 09:05 AM





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