3raser Posted June 16, 2010 Share Posted June 16, 2010 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/ Share on other sites More sharing options...
3raser Posted June 16, 2010 Author Share Posted June 16, 2010 Fixed the error for line 23, now it's line 46. Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072737 Share on other sites More sharing options...
Alex Posted June 16, 2010 Share Posted June 16, 2010 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) { Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072739 Share on other sites More sharing options...
3raser Posted June 16, 2010 Author Share Posted June 16, 2010 And if that's your full code you're also not closing the bracket opened here: if(!$session) { I close that at } else { echo "Your already logged in! <a href='index.php'>Home</a>"; } Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072740 Share on other sites More sharing options...
Alex Posted June 16, 2010 Share Posted June 16, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072742 Share on other sites More sharing options...
3raser Posted June 16, 2010 Author Share Posted June 16, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/204906-unknown-parse-error/#findComment-1072744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.