Jump to content

Unknown Parse error?


3raser

Recommended Posts

Coding my own login, and I get the following error:

 

Parse error: parse error in C:\wamp\www\project11\login.php on line 23

 

My code:

 

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

         if(!$session)
	   {
	     if (!$username || !$password)
		  {
		    echo "Please make sure you enter in all the fields: <br/>";
			 echo "<form action='login.php' method='POST'><input type='text' name='username'><br/><input type='text' name='password'><br/><input type='submit' value='Submit'></form>";
		  } else {
		   $extract = mysql_query("SELECT * FROM users WHERE username='$username'");
		   $numrows = mysql_num_rows($extract);
		   
		   while ($row = mysql_fetch assoc($extract)) 
		     {
			 $database_username = $row['username'];
			 $database_password = $row['password'];
			 }
			   $check = mysql_query("SELECT username FROM users WHERE username='$username'");
			   $exist = mysql_fetch_assoc($check);

			 if ($exist!=1) 
			   {
			     echo "No account exists with this username. <a href='login.php'>Back</a>";
			   }
			 elseif($database_username==$username && $database_password==$password) 
			  {
			    echo "You have successfully logged in. <a href='index.php'>Home</a>";
				 //session create code
  				  } else {
			    echo "Incorrect password! Please make sure you typed in the correct password. <a href='login.php'>Back</a>";
			  }
	   } else {
	   
	    echo "Your already logged in! <a href='index.php'>Home</a>";
	   }


?>

Link to comment
Share on other sites

You're forgetting an underscore on this line:

 

while ($row = mysql_fetch assoc($extract)) 

 

should be:

 

while ($row = mysql_fetch_assoc($extract)) 

 

And if that's your full code you're also not closing the bracket opened here:

 

         if(!$session)
	   {

Link to comment
Share on other sites

No you don't. You're closing the one from the else you just posted there. Try fixing the indenting on your code. It's not correct, maybe that's what's confusing you.

 

Thanks, that was the problem. Using Notepad++, I could see which brackets went to witch

 

Thanks very much for the support.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.