Jagannath Reddy
Jagannath Reddy

Reputation: 1

How do I fix Unexpected '>' Error?

I am getting this error:

Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\jagan\display.php on line 40

Here is my code:

<html>
<head><title> Display Student Results </title></head>
<body>
<form action="display.php method="post">
<table>
<tr>
<td>Enter Hallticket Number:
<td><input type="number" name="hno">
</tr>
<tr>
<td><input type="submit" name="btnsearch" value="search">
</tr>
</table>
</form>
</body>
</html>

<?php
$conn=mysqli_connect("localhost","root","")or die("unable to connect");
mysqli_select_db($conn,"college");

if(isset($_POST['btnsearch']))
{
$hall=$_POST['hno'];
$result=mysqli_connect($conn,"select * from student where hno=$hall");
echo "<h1> Student Results </h1>";
echo "<table border=5>";
echo "<tr>";
echo "<th> hallticket";
echo "<th> Name";
echo "<th> class";
echo "<th> gst";
echo "<th> Tax";
echo "<th> php";
echo "<th> dmdw";
echo "<th> accounts";
echo "</tr>;
while($rows=mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".rows['hno'];
echo "<td>".rows['name'];
echo "<td>".rows['class'];
echo "<td>".rows['gst'];
echo "<td>".rows['tax'];
echo "<td>".rows['php'];
echo "<td>".rows['dmdw'];
echo "<td>".rows['acc'];
echo "</tr>";
}
echo "</table>";
}
?>

Upvotes: 0

Views: 172

Answers (1)

Graham
Graham

Reputation: 7802

You aren't calling the mysql resultset properly, it's "row" not "rows". Here are the docs.

echo "<td>".rows['hno'];    

Should be:

echo "<td>".row['hno'];

Also, your HTML table isn't properly formed. Take a look at this resource to understand how to create a table.

You need to close off your <th> and <td> tags like this:

echo "<th>Name</th>";

Here is a great tutorial that will walk you through PHP/MySQL coding. Working your way through that first will mean less trips here to SO seeking help.

Upvotes: 0

Related Questions