Parse error: parse error, unexpected $end

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ehartwig

    Parse error: parse error, unexpected $end

    I recently created a script for user verification, solved my emailing
    issues, and then re-created the script in order to work well with the
    new PHP 5 that I installed on my server. After submitting user
    information into my creation script, I get the following error from the
    page that is suppose to insert the user data into the database, create
    a code, then send an email out for verification.

    Parse error: parse error, unexpected $end in
    c:\wamp\www\thr ead\create\add2 tbl.php on line 31

    Below are the files in which I am using:

    add2tbl.php

    <?php
    require "mailfunctions. php";
    $username = $_POST['username'];
    $md5password2 = md5($_POST['pass2']);
    $email = $_POST['email'];
    $md5password = md5($_POST['pass']);
    if(isset($_POST['username'])) {
    if ($md5password == $md5password2) {
    $db = dbc();
    $code = codegen();
    $user = insertuser($use rname, $md5password, $email, $code);
    if ($user == FALSE) {
    die("There has been an error in adding you to the Database. Please
    EMail the admin.");
    }
    else {
    echo "<b>Passwor ds do not match!</b> ";
    }
    include("/top.html");

    $mail = mailauth($usern ame);
    if ($mail) {
    echo '
    <p class = "subtitle">Succ ess! Check your email.</p>';
    } else {
    echo '
    <p class = "subtitle"> We are sorry. The request did not go through
    successfully due to an error in the Mail server. Please contact the
    Admin.</p>';

    }
    include("/bottom.html");
    }
    ?>

    mailfunctions.p hp

    <?php
    function dbc() {
    mysql_connect(l ocalhost, "root");
    mysql_select_db ("ehartwig1" );
    return TRUE;
    }
    function codegen() {
    $code = rand(1000000000 0000,9999999999 99999);
    return $code;
    }
    function insertuser($nam e,$md5password, $email,$code) {
    $query = "INSERT INTO threadauth (username, password, email,
    authcode) VALUES ('{$name}','{$m d5password}','{ $email}', '{$code}') or
    return(FALSE)";
    $result = mysql_db_query( $query);
    return $result;
    }
    function md5fetcher($nam e) {
    $query = mysql_query("SE LECT password FROM threadauth WHERE
    username='".$na me."');
    $result = mysql_fetch_arr ay($query);
    return $result['password'];
    }
    function mailfetcher($na me) {
    $query = mysql_query("SE LECT email FROM threadauth WHERE
    username='".$na me."');
    $result = mysql_fetch_arr ay($query);
    return $result['email'];
    }

    function codefetcher($na me) {
    $query = mysql_query("SE LECT authcode FROM threadauth WHERE
    username='".$na me."');
    $result = mysql_fetch_arr ay($query);
    return $result['authcode'];
    }
    function codecheck($name , $authcode) {
    $code = codefetcher($na me);
    if ($code == $authcode) {
    return TRUE;
    }
    else {
    return FALSE;
    }
    }
    function mailauth($usern ame) {
    $email = mailfetcher($us ername);
    $code = codefetcher($us ername);
    $message = "
    Subscription Request
    You have requested to receive a membership. You must follow the
    link and insert the code provided in order to activate your account.

    Username: {$username}
    Activation Code: {$code}
    http://www.ehartwig.co m/thread/activate.php?au thcode={$code}& username={$user name}

    Thank You.";
    mail($recipient , $subject, $message) or return(FALSE);
    return(TRUE);
    }
    ?>

    How can I solve this problem or what should I do differently?

  • Juliette

    #2
    Re: Parse error: parse error, unexpected $end

    Ehartwig wrote:[color=blue]
    > I recently created a script for user verification, solved my emailing
    > issues, and then re-created the script in order to work well with the
    > new PHP 5 that I installed on my server. After submitting user
    > information into my creation script, I get the following error from the
    > page that is suppose to insert the user data into the database, create
    > a code, then send an email out for verification.
    >
    > Parse error: parse error, unexpected $end in
    > c:\wamp\www\thr ead\create\add2 tbl.php on line 31
    >
    > Below are the files in which I am using:
    >
    > add2tbl.php
    >
    > <?php
    > require "mailfunctions. php";
    > $username = $_POST['username'];
    > $md5password2 = md5($_POST['pass2']);
    > $email = $_POST['email'];
    > $md5password = md5($_POST['pass']);
    > if(isset($_POST['username'])) {
    > if ($md5password == $md5password2) {
    > $db = dbc();
    > $code = codegen();
    > $user = insertuser($use rname, $md5password, $email, $code);
    > if ($user == FALSE) {
    > die("There has been an error in adding you to the Database. Please
    > EMail the admin.");
    > }
    > else {
    > echo "<b>Passwor ds do not match!</b> ";
    > }
    > include("/top.html");
    >
    > $mail = mailauth($usern ame);
    > if ($mail) {
    > echo '
    > <p class = "subtitle">Succ ess! Check your email.</p>';
    > } else {
    > echo '
    > <p class = "subtitle"> We are sorry. The request did not go through
    > successfully due to an error in the Mail server. Please contact the
    > Admin.</p>';
    >
    > }
    > include("/bottom.html");
    > }
    > ?>
    >[/color]
    <snip>


    You are missing a closing bracket in the add2tbl.php file.
    Based on the layout, my guess would be that it should come after:[color=blue]
    > if ($user == FALSE) {
    > die("There has been an error in adding you to the Database.[/color]
    Please EMail the admin.");

    Even so, could just as easily go elsewhere as your indenting is pretty
    inconsistent (I didn't study the code).

    Grz, J.

    Comment

    • Steve

      #3
      Re: Parse error: parse error, unexpected $end

      In article <436c4362$0$705 7$dbd4f001@news .wanadoo.nl>,
      jrf_no_spam@jok eaday.net (Juliette) wrote:

      [color=blue]
      > You are missing a closing bracket in the add2tbl.php file.
      > Based on the layout, my guess would be that it should come after:[color=green]
      > > if ($user == FALSE) {
      > > die("There has been an error in adding you to the[/color][/color]
      Database.[color=blue]
      > Please EMail the admin.");
      >
      > Even so, could just as easily go elsewhere as your indenting is
      > pretty inconsistent (I didn't study the code).
      >
      > Grz, J.
      >[/color]

      I'm quite sure this has been debated many times before, but I have a
      thing in my head about the way neophyte web programmers lay out their
      code.

      In the olden days ;-) we used to do it like this,

      if (statement);
      {
      if (statement);
      {
      do something;
      }
      else
      {
      do something else;
      }
      }
      else

      etc etc etc

      Most sensible PFE's will support this, but you can see straight away if
      you have unbalanced parenthesis.

      Now, because I'm an old git, and I've always done it that way, I'll
      continue, but what is the reasoning behind hiding a curly bracket at the
      end of a statement ?

      </2d>




      - Steve

      Comment

      • Sergej Andrejev

        #4
        Re: Parse error: parse error, unexpected $end

        In the nowa days i do it a bit other way but still it is more readeble
        than the example above

        Comment

        • Ehartwig

          #5
          Re: Parse error: parse error, unexpected $end

          Now I am receiving a new error on line 19:
          Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE,
          expecting T_STRING or T_VARIABLE or T_NUM_STRING in
          \thread\create\ mailfunctions.p hp on line 19

          function md5fetcher($nam e) {
          $query = mysql_query("SE LECT password FROM threadauth WHERE
          username='".$na me."');
          $result = mysql_fetch_arr ay($query);
          return $result['password'];

          line 19 = "return $result['password'];

          Your help has been appreciated,
          --Erich Hartwig

          Comment

          • Oli Filth

            #6
            Re: Parse error: parse error, unexpected $end

            Ehartwig said the following on 05/11/2005 17:48:[color=blue]
            > Now I am receiving a new error on line 19:
            > Parse error: parse error, unexpected T_ENCAPSED_AND_ WHITESPACE,
            > expecting T_STRING or T_VARIABLE or T_NUM_STRING in
            > \thread\create\ mailfunctions.p hp on line 19
            >
            > function md5fetcher($nam e) {
            > $query = mysql_query("SE LECT password FROM threadauth WHERE
            > username='".$na me."');
            > $result = mysql_fetch_arr ay($query);
            > return $result['password'];[/color]

            Check your opening/closing quote pairing...


            --
            Oli

            Comment

            • Jerry Stuckle

              #7
              Re: Parse error: parse error, unexpected $end

              Steve wrote:[color=blue]
              > In article <436c4362$0$705 7$dbd4f001@news .wanadoo.nl>,
              > jrf_no_spam@jok eaday.net (Juliette) wrote:
              >
              >
              >[color=green]
              >>You are missing a closing bracket in the add2tbl.php file.
              >>Based on the layout, my guess would be that it should come after:[color=darkred]
              >> > if ($user == FALSE) {
              >> > die("There has been an error in adding you to the[/color][/color]
              >
              > Database.
              >[color=green]
              >>Please EMail the admin.");
              >>
              >>Even so, could just as easily go elsewhere as your indenting is
              >>pretty inconsistent (I didn't study the code).
              >>
              >>Grz, J.
              >>[/color]
              >
              >
              > I'm quite sure this has been debated many times before, but I have a
              > thing in my head about the way neophyte web programmers lay out their
              > code.
              >
              > In the olden days ;-) we used to do it like this,
              >
              > if (statement);
              > {
              > if (statement);
              > {
              > do something;
              > }
              > else
              > {
              > do something else;
              > }
              > }
              > else
              >
              > etc etc etc
              >
              > Most sensible PFE's will support this, but you can see straight away if
              > you have unbalanced parenthesis.
              >
              > Now, because I'm an old git, and I've always done it that way, I'll
              > continue, but what is the reasoning behind hiding a curly bracket at the
              > end of a statement ?
              >
              > </2d>
              >
              >
              >
              >
              > - Steve[/color]

              That was one of the ways I've seen. Personally I liked

              if (statement)
              {
              do something;
              {
              else
              {
              do something else;
              }

              Makes it very easy to check your indentation and match braces. But the
              one I really don't like seems to be quite popular in PHP and Java:

              if (statement) {
              do something;
              {
              else {
              do something else;
              }


              Sure, it takes fewer lines, but it's easy to mismatch braces.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...