Imaginary Posted May 28, 2019 Share Posted May 28, 2019 Parse error: syntax error, unexpected ';' in on line 7 I been looking for a while but I think I have been over looking it. I been doing this all day so. I can not find the problem. <?php if (isset($_POST['login'])) { require 'dbh.inc.php'; $logUid = $_POST['logUid']; $logPwd = $_POST['logPwd']; if (empty($logUid) || (empty($logPwd)) { header("Location: ../login.php?error=emptyfields"); exit(); } else { $sql = "SELECT * FROM users WHERE uidUsers=?;"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: ../login.php?error=sqli"); exit(); } else { mysqli_stmt_bind_param($stmt, "s", $logUid); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) { $pwdCheck = password_verify($logPwd, $row['pwdUsers']); if ($pwdCheck == false) { header("Location: ../login.php?error=wrong"); exit(); } else if($pwdCheck == true) { session_start(); $_SESSION['username'] = $row['uidUser']; $_SESSION['email'] = $row['emailUsers']; header("Location: ../index.php?login"); exit(); } else { header("Location: ../login.php?error=usernotfound"); exit(); } } } } } else{ header("Location: ../login.php"); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/308763-need-help/ Share on other sites More sharing options...
benanamen Posted May 28, 2019 Share Posted May 28, 2019 (edited) You are missing a right parentheses. If you used a decent IDE it would have shown the error. Edited May 28, 2019 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/308763-need-help/#findComment-1567109 Share on other sites More sharing options...
Imaginary Posted May 28, 2019 Author Share Posted May 28, 2019 4 hours ago, benanamen said: You are missing a right parentheses. If you used a decent IDE it would have shown the error. Where? Quote Link to comment https://forums.phpfreaks.com/topic/308763-need-help/#findComment-1567113 Share on other sites More sharing options...
chhorn Posted May 28, 2019 Share Posted May 28, 2019 (edited) On the line before, just count them. count(open_paranthesis) === count(closing_paranthesis) Edited May 28, 2019 by chhorn Quote Link to comment https://forums.phpfreaks.com/topic/308763-need-help/#findComment-1567114 Share on other sites More sharing options...
mac_gyver Posted May 28, 2019 Share Posted May 28, 2019 actually, you have an unnecessary ( which then doesn't have a matching ), both on line #6. as to the posted logic. you have far too much code, mainly because your form and for processing code are not on the same page and you are using the mysqli database extension. if you put the form processing code on the same page as the form, stop copying variables to other variables, store validation errors in an array, switch to the much simpler php PDO database extension, and use exceptions to handle database errors, about half of the code you have now will go away. you also have a logic mistake later in the code. your 'usernotfound' condition is part of the password check logic (which can only be either true of false, there's no point in the final else statement), not as part of the fetch check logic. this type of mistake can be avoided by properly indenting your code and also by eliminating unnecessary code (see the above paragraph.) Quote Link to comment https://forums.phpfreaks.com/topic/308763-need-help/#findComment-1567115 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.