Parse error: parse error, unexpected $end in...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
snpo123
Forum Commoner
Posts: 77
Joined: Sat Apr 17, 2004 6:31 pm

Parse error: parse error, unexpected $end in...

Post by snpo123 »

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:

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>';
		}
?>
thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

simple missing a } for closing

Code: Select all

if (isset($_POST['submit'])) {
Post Reply