Click here to Skip to main content
15,440,621 members
Please Sign up or sign in to vote.
1.22/5 (3 votes)
See more:
<?php
$conn = mysqli_connect('localhost','root','','khazar');
if(!$conn){
	die("Connection failed!!!").mysqli_error();
}
else{
	echo "Connected succesfully";
}

$sql = "SELECT * FROM students";
$result = mysqli_query($conn,$sql);
if(!$result){
	die("table connection problem!");
}
// listing all datas from table
echo "<h2>List of al records: ".mysqli_num_rows($result)."</h2>";
echo "<table>";
//if(mysqli_num_rows($result)>0){
	while ($row = mysqli_fetch_assoc($result)) {
		echo $row['id']." | ".$row['name']." | ".$row['username']." | ".$row['password']."<br>";
		?>

		<form method="post" action="$_SERVER['PHP_SELF']">
		<a href="f.php? id=<?php echo $row['id']?>">DELETE</a>
		<a href="f.php? id=<?php echo $row['id']?>">EDIT</a>
		<a href="f.php? id=<?php echo $row['id']?>">UPDATE</a>

<!--	}   -->
}
<?php
if(isset($_GET['id'])){
	$id = $_GET['id'];
	$sql2 = "DELETE FROM students WHERE id=".$id;
	mysqli_query($conn,$sql2);
	header("Location:".$_SERVER['PHP_SELF']);
}
mysqli_close($conn);
?>


What I have tried:

error is:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\f.php on line 39

i changed many things and tried,but this error always exist.
please,say,what does this error mean? and what actually error is ?
Posted
Updated 4-Oct-21 18:44pm

I would try to replace
PHP
}
<?php
if(isset($_GET['id'])){

with
PHP
<?php
}
if(isset($_GET['id'])){
 
Share this answer
 
Comments
Richard Deeming 29-Sep-21 4:01am    
Hopefully the OP managed to find the error some time in the last four years. :)
Patrice T 29-Sep-21 4:19am    
oops, didn't see it :)
The "unexpected end of file" error usually means you have a php block unterminated. The parser reads off the end of the file searching for block termination, usually }.
In your case, the } right before your second <?php is the culprit. It's not in the php context, so the while loop is unterminated. Move the } after the <?php and you'll get a bit further.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900