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
https://forums.phpfreaks.com/topic/204906-unknown-parse-error/
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
https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072739
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
https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072744
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.