How to fix “syntax error, unexpected end of file” error in PHP? [closed]

只谈情不闲聊 提交于 2019-12-08 10:34:25

问题


I get this error and have tried all steps to eliminate it but can't, have also tried the steps demonstrated on stack overflow but to no avail: error:

Parse error: syntax error, unexpected end of file in C:\wamp\www\project-Feedback form\project docs\login.php on line 80

I have attached the entire snippet of code:

<?php
session_start(); // Starting Session
$error=''; // Variable To Store Error Message
?>

<html>
	<head>
		<title>Login Page</title>
		<link rel="stylesheet" type="text/css" href="login.css"> 

	</head>
	<body>
		<div id="header">
		<center><p><img src="http://www.ruparel.edu/_/rsrc/1338008090424/config/customLogo.gif?revision=29" align="left" /> <img id="image" src="http://www.auplod.com/u/pudlao4d2f7.png"  /> </p></center>
		
		</div>
		<hr></hr>
		<center><h1> Welcome to the Login page for <img src="http://www.auplod.com/u/uoalpd4d31a.png" /> </h1></center>
		<center><h2>Please Login!</h2></center>
	`	<br />
		
		<form method="post" action=" ">
		<div id="radio"><b><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQMfjN-cd00MPhHqoKOKnUHp-VP3HSU3FBuuNDJbJL2yQF0fyWR"/>Student<input type="radio" name="radio1" value="Student"></p>
		<b><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSSnk6-xJ7aCZL8aODuWyRMAENzk7XIFitACfPJALdJOaTzQq1b-w" />Professor<input type="radio" name="radio1" value="Professor"></b> </div>
		<div id="fields"><b>ROll no:<input type="text" name="username" ></b>
		<b>Password:<input type="password" name="pwd"></b><b>&nbsp;<input type="submit" name="submit" value="Login"></b></div>
		
		</form>
		
	<?php
		if (isset($_POST['submit'])) 
		{
		if (empty($_POST['username']) || empty($_POST['password'])) 
		{
		$error = "Username or Password is invalid";
		}
		else
		{
			// Define $username and $password
		$username=$_POST['username'];
		$password=$_POST['password'];
		// Establishing Connection with Server by passing server_name, user_id and password as a parameter
		$connection = mysqli_connect("localhost", "root", "");
		// To protect MySQL injection for Security purpose
		$username = stripslashes($username);
		$password = stripslashes($password);
		$username = mysqli_real_escape_string($username);
		$password = mysqli_real_escape_string($password);
		// Selecting Database
		$db = mysqli_select_db($connection,"feedback data");

		// SQL query to fetch information of registerd users and finds user match.
		$query = mysqli_query($connection,"select * from login where password='$password' AND username='$username'");
		$rows = mysqli_num_rows($query);
		if ($rows == 1) {
		$_SESSION['login_user']=$username; // Initializing Session
		//now we write php code to decide if student or teacher

		$subject=$_SESSION['login_user'];
		$pattern="/[2$]/";
		if($_POST['radio1']=="Professor"&& preg_match($pattern,$subject)==1)//condition for teacher using BRE
		{
			header("location: http://localhost/project-Feedback%20form/project%20docs/selection_page_teacher.php");
		}
		elseif($_POST['radio1']=="Student"&& preg_match($pattern,$subject)==0)//condition for student using BRE
		{
			header("location: http://localhost/project-Feedback%20form/project%20docs/selection_page_student.php");
		}
		else
		{
			echo"The selection you have made is incorrect Mr.".$_SESSION['login_user'];
		}
		mysql_close($connection); // Closing Connection
		}
		}
		
	?>
	</body>
</html>

回答1:


You're missing a closing brace } for one of your conditional statements, being for this one:

if (isset($_POST['submit']))


来源:https://stackoverflow.com/questions/28953362/how-to-fix-syntax-error-unexpected-end-of-file-error-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!