Parse error: parse error, unexpected $end in...
Posted: Tue May 18, 2004 12:37 am
Hey, I am trying to create a simple login script, and here is this php source for it. All this code is before even the begining html tag. But when I run the script it says I have a parse error on the last line of my script. I heard this error is casued by messed up up brackets, but I checked the script and it seemed fine to me. Can anybody help me with this? Here is this php code:
thanks.
Code: Select all
<?
if (isset($_POST['submit'])) {
require_once ('mysql_connect.php');
function escape_data ($data){
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes ($data);
}
return mysql_real_escape_string ($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$username = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
}else{
$username = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$password = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
}else{
$password = escape_data($_POST['password']);
}
if ($username && $password) {
$query = "SELECT user_id, username FROM users WHERE username='$username' AND password=PASSWORD('$password')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {
setcookie ('username', $row[1]);
setcookie ('user_id', $row[0]);
header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/members.php");
exit();
}else{
$message = '<p>The username and password entered does not exist in the database.</p>';
}
mysql_close();
}else{
$message .= '<p>Please try again.</p>';
}
?>