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

September 3rd, 2004, 02:31 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ch 7 page 208 commit.php
I'm getting this error message
Parse error: parse error, unexpected T_STRING, expecting ']' in /home/doesitro/public_html/commit.php on line 118
--------------
$error .= "Please+select+a+movie+year%21%0D%0A";
}
if ( empty($error) ){
$sql = "INSERT INTO <-----line 118
'movie'
( `movie_name`,
---------------------------------------
here is all the code, the code in question is toward the bottom
<?php
// COMMIT ADD AND EDITS
$error = '';
$link = mysql_connect("localhost", "doesitro_admin", "admin")
or die("Could not connect: " . mysql_error());
mysql_select_db('doesitro_wiley', $link) or die ( mysql_error());
switch( $_GET['action'] ){
case "edit":
switch( $_GET['type'] ){
case "people":
$sql = "UPDATE
'people'
SET
'people_fullname' = '".$_POST['people_fullname']."'
WHERE
'people_id' = '".$_GET['id']."'
";
break;
case "movie":
$movie_rating = trim($_POST[ 'movie_rating']);
if( !is_numeric($movie_rating)){
$error .= "Please+enter+a+numeric+rating%21%0D%0A";
} else {
if( $movie_rating < 0 || $movie_rating >10 ){
$error .= "Please+enter+a+rating+between+0+and+10%21%0D% 0A";
}
}
if ( !ereg ("([0-9] {2})-([0-9]{2})-([0-9]{4})",
$_POST['movie_release'] , $reldatepart) ){
$error .= "Please+enter+a+date+with+the+dd-mm-yyyy+format%21%0D%0A";
} else {
$movie_release = @mktime ( 0,0,0, $reldatepart['2'],
$reldatepart['1'], $reldatepart['3']);
if ( $movie_release == '-1' ){
$error .= "Please+enter+a+real+date+with+the+dd-mm-yyyy+format%21%0D%0A";
}
}
$movie_name = trim($row[ 'movie_name']);
if( empty($movie_name)){
$error .= "Please+enter+a+movie+name%21%0D%0A";
}
if( empty($_POST['movie_type'])){
$error .= "Please+select+a+movie+type%21%0D%0A";
}
if( empty($_POST['movie_year'])){
$error .= "Please+select+a+movie+year%21%0D%0A";
}
if ( empty($error) ){
$sql = "UPDATE
`movie`
SET
`movie_name`= '".$_POST['movie_name']."',
`movie_year`= '".$_POST['movie_year']."',
`movie_type`= '".$_POST['movie_type']."' ,
`movie_leadactor` = '".$_POST['movie_leadactor']."' ,
`movie_director` = '".$_POST['movie_director']."'
WHERE
'movie_id' = '".$_GET['id']."'
";
} else {
header(
"location:movie.php?action=edit&error=".$error."&i d=".$_GET['id'] );
}
break;
}
break;
case "add":
switch($_GET['type'] ){
case "people":
$sql = "INSERT INTO
'people'
('people_fullname' )
VALUES
( '".$_POST['people_fullname']."' )
";
break;
case "movie":
$movie_rating = trim($_POST[ 'movie_rating']);
if( !is_numeric($movie_rating)){
$error .= "Please+enter+a+numeric+rating%21%0D%0A";
} else {
if( $movie_rating < 0 || $movie_rating >10 ){
$error .= "Please+enter+a+rating+between+0+and+10%21%0D% 0A";
}
}
$movie_release = trim($_POST['movie_release']);
if ( !ereg ("([0-9] {2})-([0-9]{2})-([0-9]{4})", $movie_release,
$reldatepart) ||empty( $movie_release )){
$error .= "Please+enter+a+date+with+the+dd-mm-yyyy+format%21%0D%0A";
} else {
$movie_release = @mktime ( 0,0,0, $reldatepart['2'],
$reldatepart['1'], $reldatepart['3']);
if ( $movie_release == '-1' ){
$error .= "Please+enter+a+real+date+with+the+dd-mm-yyyy+format%21%0D%0A";
}
}
$movie_name = trim($_POST['movie_name']);
if(empty($movie_name)){
$error .= "Please+enter+a+movie+name%21%0D%0A";
}
if( empty($_POST['movie_type'])){
$error .= "Please+select+a+movie+type%21%0D%0A";
}
if( empty($_POST['movie_year]))){
$error .= "Please+select+a+movie+year%21%0D%0A";
}
if ( empty($error) ){
$sql = "INSERT INTO
'movie'
( `movie_name`,
`movie_year` ,
'movie_release' ,
`movie_type` ,
`movie_leadactor` ,
`movie_director`,
'movie_rating' )
VALUES
( '".$_POST['movie_name']."' ,
'".$_POST['movie_year']."' ,
'$movie_release',
'".$_POST['movie_type']."' ,
'".$_POST['movie_leadactor']."' ,
'".$_POST['movie_director']."',
'$movie_rating' )
";
} else {
header( "location:movie.php?action=add&error=".$error );
}
break;
}
break;
}
if ( isset( $sql ) && !empty( $sql )){
echo "";
$result = mysql_query( $sql )
or die("Invalid query: " . mysql_error());
?>
<p align="center" style="color:#FF0000">
Done. <a href="index.php">Index</a>
</p>
<?php
}
?>
------------------------------
Any help would be appreciated
|
|

September 8th, 2004, 12:08 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
note the missing single quote on movie_year
:D
if( empty($_POST['movie_year]))){
$error .= "Please+select+a+movie+year%21%0D%0A";
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Commit.PHP and Delete.PHP in WROX's book |
GiFos |
Beginning PHP |
0 |
January 30th, 2007 10:51 PM |
| chapter 7 commit.php |
ratxamala |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
2 |
November 2nd, 2005 09:24 AM |
| ch 6 commit.php problem updating movie table |
statusquo |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
1 |
May 2nd, 2005 10:02 PM |
| Error: movie.php & commit.php on p182-186, ch6 |
willburke |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
0 |
October 12th, 2004 02:48 PM |
| Chapter 6 commit.php |
czambran |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
4 |
October 3rd, 2004 10:20 PM |
|
 |