By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

PHP Error on Password Check (SQL Database)

P: n/a
Hi, I'm trying to get password recognition calling data froma table
called users('user_name' 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.eu/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>Password Checking Script</title>
</head>
<body>
<?php
function print_form() {
?>
<form action="check_password.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($submit)):
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($sql);
$row_count = mysql_num_rows($result);
if($row_count == 0):
?>
<h3>Wrong User Name! Try Again</h3>
<?
print_form();
else:
$row = mysql_fetch_array($result);
if($password != $row["user_password"]):
?>
<h3>Incorrect Password! Try Again</h3>
<?
print_form();
else:
?>
<h3>Password Accepted!</h3>
<?
endif;
endif;
else:
print_form();
endif;
?>
</body>
</html>

Jun 4 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Sheik Ishmael wrote:
Hi, I'm trying to get password recognition calling data froma table
called users('user_name' 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.eu/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>Password Checking Script</title>
</head>
<body>
<?php
function print_form() {
?>
<form action="check_password.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($submit)):
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($sql);
$row_count = mysql_num_rows($result);
if($row_count == 0):
?>
<h3>Wrong User Name! Try Again</h3>
<?
print_form();
else:
$row = mysql_fetch_array($result);
if($password != $row["user_password"]):
?>
<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.
js*******@attglobal.net
==================
Jun 4 '07 #2

P: n/a
Thanks Jerry

I'm working from template code downloaded from
http://authors.phptr.com/essential/php/chapter8.html

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...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Jun 4 '07 #3

P: n/a
Sheik Ishmael wrote:
Thanks Jerry

I'm working from template code downloaded from
http://authors.phptr.com/essential/php/chapter8.html

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...@attglobal.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.
js*******@attglobal.net
==================
Jun 4 '07 #4

P: n/a
Really Strange

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

--SI
Jun 4 '07 #5

P: n/a
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.
js*******@attglobal.net
==================
Jun 4 '07 #6

P: n/a
Message-ID: <Eb******************************@comcast.comfro m 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/
Jun 4 '07 #7

P: n/a
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 - sc*********@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]

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

Jun 4 '07 #8

P: n/a
On Jun 4, 12:59 pm, Schraalhans Keukenmeester
<Schraalh...@the.spamtrapexample.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.Spamtrapexample.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.

http://www.phpbuilder.com/manual/en/...ive-syntax.php

"was never valid", indeed.

~A!

Jun 5 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.