PHP Error on Password Check (SQL Database)

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

    #1

    PHP Error on Password Check (SQL Database)

    Hi, I'm trying to get password recognition calling data froma table
    called users('user_nam e' and 'user_password' using the below (bottom
    of page) code.

    However, I get the following warning from my browser

    "Parse error: parse error, unexpected ';' in /data/members/paid/g/l/
    glastonburytv.e u/htdocs/www/check_password. php3 on line 19

    This is the line I have replaced my password with "MY PASSWORD"

    Now I'm using the same connectivity activater (see line below) in
    other pages
    mysql_connect(" localhost", "glastonburytv_ eu", "MYPASSWORD ")

    Does anyone please have any ideas why I'm getting the error message on
    the ";" (line 19)

    (Full Code Below)
    Thank You
    --Sheik Ishmael

    <html>
    <head>
    <title>Passwo rd Checking Script</title>
    </head>
    <body>
    <?php
    function print_form() {
    ?>
    <form action="check_p assword.php3" method="POST">
    <h3>Please Login</h3>
    User Name: <input type="text" name="user_name ">
    <br>Password: <input type="password" name="password" >
    <input type="submit" name="submit" value="Login!">
    </form>
    <?
    }

    if(isset($submi t)):
    if(!$$db = mysql_connect(" localhost", "glastonburytv_ eu",
    "MYPASSWORD "));
    print("<h1>Can' t Connect to the DB!</h1>\n");
    else:
    mysql_select_db ("glastonburytv _eu_1");
    endif;
    $sql = "select * from users where user_name = '$user_name'";
    $result = mysql_query($sq l);
    $row_count = mysql_num_rows( $result);
    if($row_count == 0):
    ?>
    <h3>Wrong User Name! Try Again</h3>
    <?
    print_form();
    else:
    $row = mysql_fetch_arr ay($result);
    if($password != $row["user_passw ord"]):
    ?>
    <h3>Incorrect Password! Try Again</h3>
    <?
    print_form();
    else:
    ?>
    <h3>Password Accepted!</h3>
    <?
    endif;
    endif;
    else:
    print_form();
    endif;
    ?>
    </body>
    </html>

  • Jerry Stuckle

    #2
    Re: PHP Error on Password Check (SQL Database)

    Sheik Ishmael wrote:
    Hi, I'm trying to get password recognition calling data froma table
    called users('user_nam e' and 'user_password' using the below (bottom
    of page) code.
    >
    However, I get the following warning from my browser
    >
    "Parse error: parse error, unexpected ';' in /data/members/paid/g/l/
    glastonburytv.e u/htdocs/www/check_password. php3 on line 19
    >
    This is the line I have replaced my password with "MY PASSWORD"
    >
    Now I'm using the same connectivity activater (see line below) in
    other pages
    mysql_connect(" localhost", "glastonburytv_ eu", "MYPASSWORD ")
    >
    Does anyone please have any ideas why I'm getting the error message on
    the ";" (line 19)
    >
    (Full Code Below)
    Thank You
    --Sheik Ishmael
    >
    <html>
    <head>
    <title>Passwo rd Checking Script</title>
    </head>
    <body>
    <?php
    function print_form() {
    ?>
    <form action="check_p assword.php3" method="POST">
    <h3>Please Login</h3>
    User Name: <input type="text" name="user_name ">
    <br>Password: <input type="password" name="password" >
    <input type="submit" name="submit" value="Login!">
    </form>
    <?
    }
    >
    if(isset($submi t)):
    if(!$$db = mysql_connect(" localhost", "glastonburytv_ eu",
    "MYPASSWORD "));
    print("<h1>Can' t Connect to the DB!</h1>\n");
    else:
    mysql_select_db ("glastonburytv _eu_1");
    endif;
    $sql = "select * from users where user_name = '$user_name'";
    $result = mysql_query($sq l);
    $row_count = mysql_num_rows( $result);
    if($row_count == 0):
    ?>
    <h3>Wrong User Name! Try Again</h3>
    <?
    print_form();
    else:
    $row = mysql_fetch_arr ay($result);
    if($password != $row["user_passw ord"]):
    ?>
    <h3>Incorrect Password! Try Again</h3>
    <?
    print_form();
    else:
    ?>
    <h3>Password Accepted!</h3>
    <?
    endif;
    endif;
    else:
    print_form();
    endif;
    ?>
    </body>
    </html>
    >
    if statements do not have semicolons at the end of the conditional
    clause. And btw, else doesn't have a colon, either.

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

    Comment

    • Sheik Ishmael

      #3
      Re: PHP Error on Password Check (SQL Database)

      Thanks Jerry

      I'm working from template code downloaded from
      Savvas Learning Company creates award-winning education curriculum, assessments, and K-12 learning solutions to improve student outcomes.


      Is this code now out of date? Or just wrong?

      Eager to know as I'm using this book to learn from.

      best
      --Sheik Ishmael
      if statements do not have semicolons at the end of the conditional
      clause. And btw, else doesn't have a colon, either.
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===- Hide quoted text -
      >
      - Show quoted text -

      Comment

      • Jerry Stuckle

        #4
        Re: PHP Error on Password Check (SQL Database)

        Sheik Ishmael wrote:
        Thanks Jerry
        >
        I'm working from template code downloaded from
        Savvas Learning Company creates award-winning education curriculum, assessments, and K-12 learning solutions to improve student outcomes.

        >
        Is this code now out of date? Or just wrong?
        >
        Eager to know as I'm using this book to learn from.
        >
        best
        --Sheik Ishmael
        >
        >if statements do not have semicolons at the end of the conditional
        >clause. And btw, else doesn't have a colon, either.
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstuck...@attg lobal.net
        >============== ====- Hide quoted text -
        >>
        >- Show quoted text -
        >
        >
        I guess those are colons, not semicolons. It was hard to tell here.

        And no, that code is not out of date. AFAIK it was never correct in any
        version of PHP.

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

        Comment

        • Sheik Ishmael

          #5
          Re: PHP Error on Password Check (SQL Database)

          Really Strange

          The code is exactly what is reproduced in the book "Essential PHP for
          Web Developers".

          --SI


          Comment

          • Jerry Stuckle

            #6
            Re: PHP Error on Password Check (SQL Database)

            Sheik Ishmael wrote:
            Really Strange
            >
            The code is exactly what is reproduced in the book "Essential PHP for
            Web Developers".
            >
            --SI
            >
            >
            That could be. But it also doesn't mean the cod is correct.

            I don't have a copy of the book, so I can't say one way or the other.
            But I do know the code you posted is incorrect. I can only assume from
            what you're saying that the book is incorrect, also.

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

            Comment

            • Geoff Berrow

              #7
              Re: PHP Error on Password Check (SQL Database)

              Message-ID: <Eb2dnZcv_urdvP nbnZ2dnUVZ_gmdn Z2d@comcast.com from Jerry
              Stuckle contained the following:
              >That could be. But it also doesn't mean the cod is correct.
              Yeah, it's very fishy.

              --
              Geoff Berrow (put thecat out to email)
              It's only Usenet, no one dies.
              My opinions, not the committee's, mine.
              Simple RFDs http://www.ckdog.co.uk/rfdmaker/

              Comment

              • Schraalhans Keukenmeester

                #8
                Re: PHP Error on Password Check (SQL Database)

                At Mon, 04 Jun 2007 05:09:03 -0700, Sheik Ishmael let h(is|er) monkeys
                type:
                Really Strange
                >
                The code is exactly what is reproduced in the book "Essential PHP for
                Web Developers".
                >
                --SI
                I don't recall : ever being syntactically correct following an if () or
                else. But even if it ever was, it isn't anymore. The online source is
                wrong. Besides your copy here isn't a 100% copy of the one in the page you
                referred to, you put a ; where the code has a :

                It probably works if you remove all the : following if/elses, but I'd have
                my doubts about the dubious quality of the work altogether and find
                something better.

                All code was written when php3 was standard. We're at 5 now, you will find
                many version 4 scripts and hosts, but no php3 ones anymore. (Now someone
                probably shows me a link to a host using php3 or even older....)

                www.php.net is a good starting point.

                --
                Schraalhans Keukenmeester - schraalhans@the .Spamtrapexampl e.nl
                [Remove the lowercase part of Spamtrap to send me a message]

                "strcmp('apples ','oranges') < 0"

                Comment

                • mypetprogrammer@gmail.com

                  #9
                  Re: PHP Error on Password Check (SQL Database)

                  On Jun 4, 12:59 pm, Schraalhans Keukenmeester
                  <Schraalh...@th e.spamtrapexamp le.nlwrote:
                  At Mon, 04 Jun 2007 05:09:03 -0700, Sheik Ishmael let h(is|er) monkeys
                  type:
                  >
                  Really Strange
                  >
                  The code is exactly what is reproduced in the book "Essential PHP for
                  Web Developers".
                  >
                  --SI
                  >
                  I don't recall : ever being syntactically correct following an if () or
                  else. But even if it ever was, it isn't anymore. The online source is
                  wrong. Besides your copy here isn't a 100% copy of the one in the page you
                  referred to, you put a ; where the code has a :
                  >
                  It probably works if you remove all the : following if/elses, but I'd have
                  my doubts about the dubious quality of the work altogether and find
                  something better.
                  >
                  All code was written when php3 was standard. We're at 5 now, you will find
                  many version 4 scripts and hosts, but no php3 ones anymore. (Now someone
                  probably shows me a link to a host using php3 or even older....)
                  >
                  www.php.netis a good starting point.
                  >
                  --
                  Schraalhans Keukenmeester - schraalh...@the .Spamtrapexampl e.nl
                  [Remove the lowercase part of Spamtrap to send me a message]
                  >
                  "strcmp('apples ','oranges') < 0"
                  Actually, the colon thing is perfectly acceptable syntax.

                  if (condition):

                  else:

                  endif;

                  Is valid PHP code. It also works for switch, while, for, foreach, etc.



                  "was never valid", indeed.

                  ~A!

                  Comment

                  Working...