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

May 23rd, 2004, 05:52 AM
|
Registered User
|
|
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

May 24th, 2004, 06:08 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
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
::::::::::::::::::::::::::::::::::::::::::
|

May 24th, 2004, 06:10 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
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
::::::::::::::::::::::::::::::::::::::::::
|

May 26th, 2004, 12:30 PM
|
Registered User
|
|
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |