Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 May 23rd, 2004, 05:52 AM
Registered User
 
Join Date: May 2004
Location: , , .
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.

Reply With Quote
  #2 (permalink)  
Old May 24th, 2004, 06:08 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #3 (permalink)  
Old May 24th, 2004, 06:10 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #4 (permalink)  
Old May 26th, 2004, 12:30 PM
Registered User
 
Join Date: May 2004
Location: , , .
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

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



All times are GMT -4. The time now is 08:26 PM.


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