silverglade Posted July 5, 2011 Share Posted July 5, 2011 Hi I have this user login, it gives me an error on the page as "unexpected syntax error, ')' . I cannot find the unnecessary extra parenthesis. please any help greatly appreciated. thank you. <?php session_start(); require("connect.php"); $post_username = $_POST['username']; $post_password = $_POST['password']; if($post_username && $post_password) { if (strlen($post_username) >25) || strlen($post_password) < 15)) echo ("Username or password character length too long!") else { //convert password to md5 $post_password = md5($post_password); //query the database $login = sprintf("SELECT * FROM users WHERE username='$%s' AND password='%s'", mysql_real_escape_string($post_username), mysql_real_escape_string($post_password); $rowcount = mysql_num_rows(mysql_query($login)); if($rowcount==1) { //log the user in $_SESSION['user']=$post_username; $_SESSION['user'].", you have been logged in! <a href="index.php">Return</a> to the main page."; } else die("Incorrect username or password combination") } //end top if ?> Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/ Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 You are missing two "}" closing tag in the very end. Alsi fixed this line: if ((strlen($post_username) > 25) || (strlen($post_password) < 15)) I suggest you get some good IDE with syntax highlighting and possibility to see the starting and ending tags easily. Helps alot in errors like this. edit: You are also missing the starting "{" in your else clause. Huh. edit2: This line is also missing ending ")" $login = sprintf("SELECT * FROM users WHERE username='$%s' AND password='%s'", mysql_real_escape_string($post_username), mysql_real_escape_string($post_password)); Maybe pay attention a bit more in the opening and closing tags? Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/#findComment-1238562 Share on other sites More sharing options...
EdwinPaul Posted July 5, 2011 Share Posted July 5, 2011 First of all: you cannot use if($post_username && $post_password) as if it were 2 booleans. They are NOT ! Second: <?php if (strlen($post_username) >25) || strlen($post_password) < 15)) ?> <?php if ( (strlen($post_username) >25) || (strlen($post_password) < 15) ) ?> Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/#findComment-1238564 Share on other sites More sharing options...
PFMaBiSmAd Posted July 5, 2011 Share Posted July 5, 2011 Line 10 has two extra ) in it. All you need is - if (strlen($post_username) >25 || strlen($post_password) < 15) Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/#findComment-1238566 Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 Yeah that goes also, sometimes it might be easier to picture it with some extra parenthesis. In a whole that code is a total mess. Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/#findComment-1238567 Share on other sites More sharing options...
silverglade Posted July 5, 2011 Author Share Posted July 5, 2011 Thank you everyone. I think I am going to do another tutorial because this guy cannot program. I find the tutorials on the net or even youtube for image galleries. One uses Dreamweaver to do it which I did not want. and the other can't code. I will have to search again. Thank God I have backups of my original website code before I started messing with these tutorials! thanks. Quote Link to comment https://forums.phpfreaks.com/topic/241133-user-login-error-on-line-10-unexpected/#findComment-1238570 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.