0

私のエラーは何ですか?

解析エラー: 構文エラー、14 行目の public_html/sign_up.php の予期しない T_VARIABLE

私の人生では、自分が何を間違えたのか理解できません。

    include_once("../php/sign_up/connect_db.php");

    // Array for JSON response
    $response = array();

    // Check for required fields
    if (isset($_POST['firstname']) &&
        isset($_POST['surname'])   &&
        isset($_POST['postcode'])  &&
        isset($_POST['email'])     &&
        isset($_POST['phone'])

        $firstname = $_POST['firstname'];
        $surname   = $_POST['surname'];
        $postcode  = $_POST['postcode'];
        $email     = $_POST['email'];
        $phone     = $_POST['phone'];

        // Connecting to db
        $db = new DB_CONNECT();

        // MySQL inserting a new row
        $result = mysql_query("INSERT INTO TABLE 1(firstname, surname, postcode, phone, email) VALUES('$firstname', '$surname', '$postcode', '$phone', '$email')");

        // Check if row is inserted or not
        if ($result) {
            // Successfully inserted into database
            $response["success"] = 1;
            $response["message"] = "Thank you for registering.";

            // Echoing JSON response
            echo json_encode($response);
        } else {
            // Failed to insert row
            $response["success"] = 0;
            $response["message"] = "Oops! An error occurred.";

            // Echoing JSON response
            echo json_encode($response);
        }
    }
    else {
        // Required field is missing
        $response["success"] = 0;
        $response["message"] = "Required field(s) is missing";

        // Echoing JSON response
        echo json_encode($response);
    }
?>
4

2 に答える 2

3

if 括弧を閉じるのを忘れていました:

変化する

if (isset($_POST['firstname']) && isset($_POST['surname']) && isset($_POST['postcode'])&& isset($_POST['email']) && isset($_POST['phone'])

if (isset($_POST['firstname']) && isset($_POST['surname']) && isset($_POST['postcode'])&& isset($_POST['email']) && isset($_POST['phone']))
于 2013-04-12T20:53:02.123 に答える
1

閉じ括弧がありません:

if ( isset($_POST['firstname']) && isset($_POST['surname']) && isset($_POST['postcode'])
     && isset($_POST['email']) && isset($_POST['phone']) )
                                                         ^ here
{
^ you probably want this too as you do have the 'else' and closing brackets
于 2013-04-12T20:53:27.167 に答える