chriscloyd Posted December 5, 2008 Share Posted December 5, 2008 this is the error im getting Parse error: syntax error, unexpected T_ELSE in /home/cpc/public_html/process/login.php on line 34 this is my code can someone help me there <?php session_start(); mysql_connect('localhost','*******','*******'); mysql_select_db('*******'); $username = mysql_real_escape_string($_POST['username']); if ($username == NULL) { $error = 1; $_SESSION['*******'] = 'No username entered.'; } $password = mysql_real_escape_string($_POST['password']); $password = md5($password); if ($password == NULL) { $error = 1; $_SESSION['*******'] = 'No password entered.'; } if ($error == 1) { header("Location: ../index.php"); } else { $check_username = mysql_query("SELECT * FROM users WHERE username = '".$username."'"); $num_users = mysql_num_rows($check_users); if ($num_users > 0) { $user_info = mysql_fetch_assoc($check_username); if ($user_info['password'] == $password); $_SESSION['*******'] = $username; $check_admin = mysql_query("SELECT * FROM admins WHERE uid = '".$user_info['uid']."'"); $num_admins = mysql_num_rows($check_admin); if ($num_admins > 0) { $_SESSION['*******'] = 'yes'; } } else { $_SESSION['*******'] = 'Incorrect information.'; header("Location: ../index.php"); } } else { $_SESSION['*******'] = 'No account for that username.'; header("Location: ../index.php"); } } ?> Quote Link to comment Share on other sites More sharing options...
balistic Posted December 5, 2008 Share Posted December 5, 2008 you have two elses, without an else if line 18 Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 5, 2008 Author Share Posted December 5, 2008 no they are all there bro Quote Link to comment Share on other sites More sharing options...
balistic Posted December 5, 2008 Share Posted December 5, 2008 yes, they are, but you have two elses aligning at the moment. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 5, 2008 Author Share Posted December 5, 2008 please show me wear lol i just looked and i dont see 2 elses lined up anywear Quote Link to comment Share on other sites More sharing options...
petersro Posted December 5, 2008 Share Posted December 5, 2008 line 34 and line 38, if im not mistaken, they will error out as they dont flow, Quote Link to comment Share on other sites More sharing options...
balistic Posted December 5, 2008 Share Posted December 5, 2008 light blue, is what i mean, dark blue is where you seem to have made the mistake. line 18 and 34 Else's Quote Link to comment Share on other sites More sharing options...
balistic Posted December 5, 2008 Share Posted December 5, 2008 I think you mean like <?php session_start(); mysql_connect('localhost','*******','*******'); mysql_select_db('*******'); $username = mysql_real_escape_string($_POST['username']); if ($username == NULL) { $error = 1; $_SESSION['*******'] = 'No username entered.'; } $password = mysql_real_escape_string($_POST['password']); $password = md5($password); if ($password == NULL) { $error = 1; $_SESSION['*******'] = 'No password entered.'; } if ($error == 1) { header("Location: ../index.php"); } else{ $check_username = mysql_query("SELECT * FROM users WHERE username = '".$username."'"); $num_users = mysql_num_rows($check_users); if ($num_users > 0) { $user_info = mysql_fetch_assoc($check_username); if ($user_info['password'] == $password) { $_SESSION['*******'] = $username; $check_admin = mysql_query("SELECT * FROM admins WHERE uid = '".$user_info['uid']."'"); $num_admins = mysql_num_rows($check_admin); if ($num_admins > 0) { $_SESSION['*******'] = 'yes'; } } else{ $_SESSION['*******'] = 'Incorrect information.'; header("Location: ../index.php"); } } else{ $_SESSION['*******'] = 'No account for that username.'; header("Location: ../index.php"); } } ?> Quote Link to comment Share on other sites More sharing options...
petersro Posted December 5, 2008 Share Posted December 5, 2008 aye sorry my bad, just a quick question why have 2 error statements, just rope it all into one else wrong info so like, if this, else if that, else die wrong info Quote Link to comment 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.