Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default PHP help please? :)

    I get this error:
    Parse error: syntax error, unexpected T_ELSE in /home/name/public_html/derek/email_sub.php on line 15

    Code:
    PHP Code:
    <?php

    session_start
    ();
    include 
    'includes/db.php';

    if (isset(
    $_POST['sub'])) {
    if(!
    $_POST['email']) {
    echo 
    "You didn't submit and email!";
    } else {
    $emails mysql_query("SELECT * FROM `email`");
    $emailss mysql_fetch_array($emails);
    if (
    $emailss 1) {
    echo 
    "This email is already subscribed to our newsletter!";
    }
    } else {
            
    $email htmlspecialchars($_POST['email']);
            
    $add mysql_query("INSERT INTO `subscribers` (`email`) VALUES('$email')");
            echo 
    "Thanks for subscribing to $sitename!";
    }
    } else {
    echo 
    "<form method='post' action='$_SERVER[PHP_SELF]'>
    Email:<br>
    <input type='text' name='email' size='20'><br>
    <input type='submit' name='sub' value='Submit'>
    </form>"
    ;
    }

    ?>
    Back for a while.

  2. #2
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    PHP Code:
    <?php

    session_start
    ();
    include 
    'includes/db.php';

    if (isset(
    $_POST['sub'])) {
    if(!
    $_POST['email']) {
    echo 
    "You didn't submit and email!";
    } else {
    $emails mysql_query("SELECT * FROM `email`");
    $emailss mysql_fetch_array($emails);
    if (
    $emailss 1) {
    echo 
    "This email is already subscribed to our newsletter!";
    }
     else {
            
    $email htmlspecialchars($_POST['email']);
            
    $add mysql_query("INSERT INTO `subscribers` (`email`) VALUES('$email')");
            echo 
    "Thanks for subscribing to $sitename!";
    }
    }
    }
     else {
    echo 
    "<form method='post' action='$_SERVER[PHP_SELF]'>
    Email:<br>
    <input type='text' name='email' size='20'><br>
    <input type='submit' name='sub' value='Submit'>
    </form>"
    ;
    }


    ?>
    try that?
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  3. #3
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    There is no opening if block for the following else block:
    PHP Code:
    } else {
    echo 
    "<form method='post' action='$_SERVER[PHP_SELF]'>
    Email:<br>
    <input type='text' name='email' size='20'><br>
    <input type='submit' name='sub' value='Submit'>
    </form>"
    ;


  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    ever heard of indentation?


    www.fragme.co = a project.

  5. #5
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    You had two ending brackets, so it didn't have anything to check else against

  6. #6
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Stupid stupid mistake guys, thanks for the help +rep to all.
    Back for a while.

Posting Permissions

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