View Single Post
 
Old October 16th, 2004, 08:07 PM
willburke willburke is offline
Registered User
 
Join Date: Oct 2004
Location: , , Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to willburke
Default Parse error: CH7 p198

Hello people, This book is great, I'm finding acouple of errors that I can't solve.

Parse error: parse error, unexpected '}', expecting ']' in E:\web\test\chapter7\commit.php on line 67

my code is as follows:

<?php
    //COMMIT ADD AND EDITS
    $error = '';
    //Connect to the mysql server
    $link = mysql_connect("localhost","root","xxxxxxxxx") or die("Could not connect: " . mysql_error());

    //Use the correct database
    mysql_select_db('wiley',$link) or die(mysql_error());

    //Code Commit Action
    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_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=".$er ror."&id=".$_GET['id']);
                    }
                    break;
            }
            break;

        case "add":
            switch($_GET['type'])
            {
                case "people":
                    $sql = "INSERT INTO
                                              people(people_fullname)
                    VALUES // Line 67
                                ('".$_POST['people_fullname']."')
                           ";
                    break;
                case "movie":
                    $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 = "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']."')
                            ";
                    }
                    else
                    {
                        header("location:movie.php?action=add&error=".$err or);
                    }
                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 a great help!

Thank you
will burke