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"); } } ?> Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/ 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 Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706543 Share on other sites More sharing options...
chriscloyd Posted December 5, 2008 Author Share Posted December 5, 2008 no they are all there bro Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706545 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. Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706547 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 Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706548 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, Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706549 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 Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706553 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"); } } ?> Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706554 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 Link to comment https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.