I'm relatively new to php and have only started learning. There is an error on line 12 that says "Parse error: syntax error, unexpected T_STRING". I was hoping someone could point me in the right direction as to why I'm getting this error. Thank you.
Added the whole block of code as I notice I only to the point of where the error was.
session_start(); echo '<link rel="stylesheet" href= "pass.css" type="text/css">'; if (isset($_POST['loginName']) && isset($_POST['passWord'])) { $attempts = $_SESSION['attempts']; $sql = "SELECT * FROM password WHERE loginName = '$_POST[loginName]' AND passWord = '$_POST[passWord]' if (!mysqli_query($con, $sql)) echo "Error in query ". mysqli_error($con); <-- line 12 else { if (mysqli_affected_rows($con) == 0) { $attempts++; if ($attempts <=3) { $_SESSION['attempts'] = $attempts; buildPage($attempts); echo "<div class ='errorstyle'> No record found with this login name and password combination<br> shutting down ... </div>"; } else { echo "<div class ='errorstyle'> Sorry - you have used all 3 attempts<br> shutting down ... </div>"; $_SESSION['user'] = $_POST['loginName']; echo " <h2> Login Succesful!</h2> <h2> Welcome to Our Website</h2> <h3> Do you want to change password or go directly to the main menu?</h3> <input type = 'button' value = 'Change Password' onclick = 'window.location = \"changePassword\"'> <input type = 'button' value = 'Main Menu' onclick = 'window.location' = \"menu.php"\"'> } } } else { $attempts = 1; $_SESSION['attempts'] = $attempts; buildPage($attempts); }; function buildPage($att) { echo " <body> <form action = 'loginScreen.php' method = 'post'> <h1> Our Website </h1> <h2>Attempt Number: $att </h2> <label for ='loginName'>Login Name</label> <input type = 'text' name = 'loginName' id = 'loginName' autocomplete = 'off'/><br><br> <label for = 'password'>Password</label> <input type = 'password' name = 'passWord' id = 'passWord ><br><br> <input type = 'submit' value = 'Submit'> </form>"; } mysqli_close($con); ?>
https://stackoverflow.com/questions/67377677/error-on-line-12-parse-error-syntax-error-unexpected-t-string-php-cant-find May 04, 2021 at 09:28AM
没有评论:
发表评论