Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Location
    Austin, Texas
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can someone help with me figure out this error

    I am working on a mailing list application for a client that will enable people to subscribe and unsubscribe from the mailing list. I am getting the following error message:

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/skinsens/public_html/manage.php on line 25

    Can someone help point out how to correct this error? Below is the code to the page.

    <?php
    include 'scripts/include.php';

    //determine if they need to see the form or not
    if (!$_POST)
    {
    //they need to see the form, create form block
    $display_block = <<<END_OF_BLOCK
    <form method="POST" action="{$_SERVER['PHP_SELF']}">
    <p><label for="email">Your E-Mail Address:</label></br>
    <input type="text" id="email" name="email" size="40" maxlength="150" /></p>

    <fieldset>
    <legend>Action:</legend></br>
    <input type="radio" id="action_sub" name="action" value="sub" checked />
    <label for="action_sub">subscribe</label></br>
    <input type="radio" id="action_unsub" name="action" value="unsub" checked />
    <label for="action_unsub">unsubscribe</label></br>
    </fieldset>

    <input name="submit" type="button" value="submit">
    </form>
    END_OF_BLOCK;
    }
    else if (($_POST) && ($_POST['action'] == "sub")) ***THIS IS LINE 25***
    {
    //trying to subscribe, validate email address
    if ($_POST['email'] == "")
    {
    header("Location: manage.php");
    exit;
    }
    else
    {
    //connect to database
    dbconnect();

    //check that email is in list
    emailChecker($_POST['email']);

    //get the mumber of results and do action
    if (mysqli_num_rows($check_res) < 1)
    {
    //free result
    mysqli_free_result($check_res);

    //add record
    $add_sql = "INSERT INTO subscribers (email) VALUES('".$safe_email."')";
    $add_res = mysqli_query($mysqli, $add_sql) or die(mysqli_error($mysqli));
    $display_block = "<p>Thanks for signing up!</p>";

    //close connection to mysql
    mysqli_close($mysqli);
    }
    else
    {
    //print failure message
    $display_block = "<p>You're already subscribed!</p>";
    }
    }
    }
    else if (($_POST) && ($_POST['action'] == "unsub"))
    {
    //trying to unsubscribe, validate email address
    if ($_POST['email'] == "")
    {
    header("Location: manage.php");
    exit;
    }
    else
    {
    //connect to database
    dbconnect();

    //check that email is in the list
    emailChecker($_POST['email']);

    //get the number of results and do action
    if (mysqli_num_rows($check_res) < 1)
    {
    //free result
    mysqli_free_result($check_res);

    //print failure message
    $display_block = "<p>Couldn't find your email address!</p>
    <p>No action was taken.</p>";
    }
    else
    {
    //get value of ID from result
    while ($row = mysqli_fetch_array($check_res))
    {
    $id = $row['id'];
    }

    //unsubscribe the email address
    $del_sql = "DELETE FROM subscribers WHERE id = ".$id;
    $del_res = mysqli_query($mysqli_error($mysqli));
    $display_block = "<p>You're unsubscribed!</p>";
    }
    mysqli_close($mysqli);
    }
    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Subscribe/Unsubscribe to our Mailing List</title>
    </head>

    <body>
    <h1>Subscribe/Unsubscribe to our Mailing List</h1>
    <?php echo $display_block; ?>
    </body>
    </html>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Is this the same as the last problem?
    The errors are the same thing. Whitespace preceding the END_OF_BLOCK; and and a closing } with no corresponding open.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •